title: Undefined symbols for architecture x86_64 c++ on Mac
body: <p>Hi I have wrote a program in C++ in Netbeans on Macintosh that uses these these includes - iostream,fstream, string &amp; cstdlib. The program compiles fine in Netbeans but I need to compile and run it with gcc because I need to pass an Image File to the program in terminal.</p>
  
  <p>When I try to compile I get the error below and to be honest I am completely lost as to what is going on. It seems there is an issue with the namespace? Anyone able to help?</p>
  
  <p>Thanks!</p>
  
  <pre><code>    Macintosh-2:ImageTool root$ gcc main.cpp -o main.out
  Undefined symbols for architecture x86_64:
    "std::__1::locale::has_facet(std::__1::locale::id&amp;) const", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "std::__1::locale::use_facet(std::__1::locale::id&amp;) const", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::imbue(std::__1::locale const&amp;) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "std::__1::ios_base::getloc() const", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
    "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::__init(char const*, unsigned long)", referenced from:
        Partition_Info::getFileSystemType() in main-f0eaa5.o
        DirectoryEntry::getNameOfFile() in main-f0eaa5.o
        FileContents::getFileContents() in main-f0eaa5.o
    "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::__init(unsigned long, char)", referenced from:
        std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt; std::__1::__pad_and_output&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;, char const*, char const*, char const*, std::__1::ios_base&amp;, char) in main-f0eaa5.o
    "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::assign(char const*)", referenced from:
        Partition_Info::getFileSystemType() in main-f0eaa5.o
    "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::~basic_string()", referenced from:
        Partition_Info::getFileSystemType() in main-f0eaa5.o
        _main in main-f0eaa5.o
        std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt; std::__1::__pad_and_output&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;, char const*, char const*, char const*, std::__1::ios_base&amp;, char) in main-f0eaa5.o
    "std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::read(char*, long)", referenced from:
        _main in main-f0eaa5.o
    "std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::seekg(long long, std::__1::ios_base::seekdir)", referenced from:
        _main in main-f0eaa5.o
    "std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_istream()", referenced from:
        construction vtable for std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;-in-std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_istream()", referenced from:
        construction vtable for std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;-in-std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_istream()", referenced from:
        _main in main-f0eaa5.o
        std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_ifstream() in main-f0eaa5.o
    "std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::put(char)", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-f0eaa5.o
    "std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::flush()", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-f0eaa5.o
    "std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sentry::sentry(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;)", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
    "std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sentry::~sentry()", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
    "std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::operator&lt;&lt;(bool)", referenced from:
        _main in main-f0eaa5.o
    "std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::operator&lt;&lt;(int)", referenced from:
        _main in main-f0eaa5.o
    "std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::operator&lt;&lt;(unsigned int)", referenced from:
        _main in main-f0eaa5.o
    "std::__1::basic_streambuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::uflow()", referenced from:
        vtable for std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "std::__1::basic_streambuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::xsgetn(char*, long)", referenced from:
        vtable for std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "std::__1::basic_streambuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::xsputn(char const*, long)", referenced from:
        vtable for std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "std::__1::basic_streambuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::showmanyc()", referenced from:
        vtable for std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "std::__1::basic_streambuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_streambuf()", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "std::__1::basic_streambuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_streambuf()", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_filebuf() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "std::__1::cout", referenced from:
        _main in main-f0eaa5.o
    "std::__1::ctype&lt;char&gt;::id", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
    "std::__1::locale::locale(std::__1::locale const&amp;)", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "std::__1::locale::~locale()", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "std::__1::codecvt&lt;char, char, __mbstate_t&gt;::id", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::imbue(std::__1::locale const&amp;) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
    "std::__1::ios_base::init(void*)", referenced from:
        _main in main-f0eaa5.o
    "std::__1::ios_base::clear(unsigned int)", referenced from:
        _main in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
    "std::__1::basic_ios&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_ios()", referenced from:
        _main in main-f0eaa5.o
        std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_ifstream() in main-f0eaa5.o
    "std::bad_cast::bad_cast()", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sync() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::underflow() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::overflow(int) in main-f0eaa5.o
    "std::bad_cast::~bad_cast()", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sync() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::underflow() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::overflow(int) in main-f0eaa5.o
    "std::terminate()", referenced from:
        ___clang_call_terminate in main-f0eaa5.o
    "typeinfo for std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;", referenced from:
        construction vtable for std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;-in-std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
        typeinfo for std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "typeinfo for std::__1::basic_streambuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;", referenced from:
        typeinfo for std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "typeinfo for std::bad_cast", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sync() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::underflow() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::overflow(int) in main-f0eaa5.o
    "vtable for __cxxabiv1::__si_class_type_info", referenced from:
        typeinfo for std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
        typeinfo for std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
    "vtable for std::__1::ios_base", referenced from:
        _main in main-f0eaa5.o
    NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
    "vtable for std::__1::basic_ios&lt;char, std::__1::char_traits&lt;char&gt; &gt;", referenced from:
        _main in main-f0eaa5.o
    NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
    "non-virtual thunk to std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_istream()", referenced from:
        construction vtable for std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;-in-std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "non-virtual thunk to std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_istream()", referenced from:
        construction vtable for std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;-in-std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt; in main-f0eaa5.o
    "operator delete[](void*)", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_filebuf() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::imbue(std::__1::locale const&amp;) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::setbuf(char*, long) in main-f0eaa5.o
    "operator delete(void*)", referenced from:
        std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_ifstream() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_filebuf() in main-f0eaa5.o
    "operator new[](unsigned long)", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::imbue(std::__1::locale const&amp;) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::setbuf(char*, long) in main-f0eaa5.o
    "___cxa_allocate_exception", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sync() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::underflow() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::overflow(int) in main-f0eaa5.o
    "___cxa_begin_catch", referenced from:
        ___clang_call_terminate in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_filebuf() in main-f0eaa5.o
    "___cxa_call_unexpected", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::close() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::basic_filebuf() in main-f0eaa5.o
    "___cxa_end_catch", referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_filebuf() in main-f0eaa5.o
    "___cxa_throw", referenced from:
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sync() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::underflow() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::overflow(int) in main-f0eaa5.o
    "___gxx_personality_v0", referenced from:
        Partition_Info::getFileSystemType() in main-f0eaa5.o
        _main in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in main-f0eaa5.o
        std::__1::basic_ifstream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::~basic_ifstream() in main-f0eaa5.o
        std::__1::basic_filebuf&lt;char, std::__1::char_traits&lt;char&gt; &gt;::close() in main-f0eaa5.o
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in main-f0eaa5.o
        std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt; std::__1::__pad_and_output&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;, char const*, char const*, char const*, std::__1::ios_base&amp;, char) in main-f0eaa5.o
        ...
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>