Mac上的体系结构x86_64 c ++的未定义符号

时间:2015-04-12 15:05:08

标签: c++ gcc std

您好我在Macintosh上的Netbeans中用C ++编写了一个程序,使用这些包括 - iostream,fstream,string& cstdlib。该程序在Netbeans中编译得很好,但我需要使用gcc编译和运行它,因为我需要将一个图像文件传递给终端中的程序。

当我尝试编译时,我得到下面的错误,说实话,我完全迷失了发生了什么。似乎命名空间存在问题?有人能帮忙吗?

谢谢!

    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&) const", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-f0eaa5.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::imbue(std::__1::locale const&) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "std::__1::ios_base::getloc() const", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-f0eaa5.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__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<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
      std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in main-f0eaa5.o
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*)", referenced from:
      Partition_Info::getFileSystemType() in main-f0eaa5.o
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
      Partition_Info::getFileSystemType() in main-f0eaa5.o
      _main in main-f0eaa5.o
      std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in main-f0eaa5.o
  "std::__1::basic_istream<char, std::__1::char_traits<char> >::read(char*, long)", referenced from:
      _main in main-f0eaa5.o
  "std::__1::basic_istream<char, std::__1::char_traits<char> >::seekg(long long, std::__1::ios_base::seekdir)", referenced from:
      _main in main-f0eaa5.o
  "std::__1::basic_istream<char, std::__1::char_traits<char> >::~basic_istream()", referenced from:
      construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_ifstream<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "std::__1::basic_istream<char, std::__1::char_traits<char> >::~basic_istream()", referenced from:
      construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_ifstream<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "std::__1::basic_istream<char, std::__1::char_traits<char> >::~basic_istream()", referenced from:
      _main in main-f0eaa5.o
      std::__1::basic_ifstream<char, std::__1::char_traits<char> >::~basic_ifstream() in main-f0eaa5.o
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-f0eaa5.o
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-f0eaa5.o
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(bool)", referenced from:
      _main in main-f0eaa5.o
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(int)", referenced from:
      _main in main-f0eaa5.o
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(unsigned int)", referenced from:
      _main in main-f0eaa5.o
  "std::__1::basic_streambuf<char, std::__1::char_traits<char> >::uflow()", referenced from:
      vtable for std::__1::basic_filebuf<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "std::__1::basic_streambuf<char, std::__1::char_traits<char> >::xsgetn(char*, long)", referenced from:
      vtable for std::__1::basic_filebuf<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "std::__1::basic_streambuf<char, std::__1::char_traits<char> >::xsputn(char const*, long)", referenced from:
      vtable for std::__1::basic_filebuf<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "std::__1::basic_streambuf<char, std::__1::char_traits<char> >::showmanyc()", referenced from:
      vtable for std::__1::basic_filebuf<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "std::__1::basic_streambuf<char, std::__1::char_traits<char> >::basic_streambuf()", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "std::__1::basic_streambuf<char, std::__1::char_traits<char> >::~basic_streambuf()", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::~basic_filebuf() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "std::__1::cout", referenced from:
      _main in main-f0eaa5.o
  "std::__1::ctype<char>::id", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-f0eaa5.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
  "std::__1::locale::locale(std::__1::locale const&)", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "std::__1::locale::~locale()", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-f0eaa5.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "std::__1::codecvt<char, char, __mbstate_t>::id", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::imbue(std::__1::locale const&) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, 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<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
  "std::__1::basic_ios<char, std::__1::char_traits<char> >::~basic_ios()", referenced from:
      _main in main-f0eaa5.o
      std::__1::basic_ifstream<char, std::__1::char_traits<char> >::~basic_ifstream() in main-f0eaa5.o
  "std::bad_cast::bad_cast()", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::sync() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::underflow() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::overflow(int) in main-f0eaa5.o
  "std::bad_cast::~bad_cast()", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::sync() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::underflow() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::overflow(int) in main-f0eaa5.o
  "std::terminate()", referenced from:
      ___clang_call_terminate in main-f0eaa5.o
  "typeinfo for std::__1::basic_istream<char, std::__1::char_traits<char> >", referenced from:
      construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_ifstream<char, std::__1::char_traits<char> > in main-f0eaa5.o
      typeinfo for std::__1::basic_ifstream<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "typeinfo for std::__1::basic_streambuf<char, std::__1::char_traits<char> >", referenced from:
      typeinfo for std::__1::basic_filebuf<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "typeinfo for std::bad_cast", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::sync() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::underflow() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::overflow(int) in main-f0eaa5.o
  "vtable for __cxxabiv1::__si_class_type_info", referenced from:
      typeinfo for std::__1::basic_ifstream<char, std::__1::char_traits<char> > in main-f0eaa5.o
      typeinfo for std::__1::basic_filebuf<char, std::__1::char_traits<char> > 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<char, std::__1::char_traits<char> >", 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<char, std::__1::char_traits<char> >::~basic_istream()", referenced from:
      construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_ifstream<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "non-virtual thunk to std::__1::basic_istream<char, std::__1::char_traits<char> >::~basic_istream()", referenced from:
      construction vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >-in-std::__1::basic_ifstream<char, std::__1::char_traits<char> > in main-f0eaa5.o
  "operator delete[](void*)", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::~basic_filebuf() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::imbue(std::__1::locale const&) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::setbuf(char*, long) in main-f0eaa5.o
  "operator delete(void*)", referenced from:
      std::__1::basic_ifstream<char, std::__1::char_traits<char> >::~basic_ifstream() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::~basic_filebuf() in main-f0eaa5.o
  "operator new[](unsigned long)", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::imbue(std::__1::locale const&) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::setbuf(char*, long) in main-f0eaa5.o
  "___cxa_allocate_exception", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::sync() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::underflow() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::overflow(int) in main-f0eaa5.o
  "___cxa_begin_catch", referenced from:
      ___clang_call_terminate in main-f0eaa5.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::~basic_filebuf() in main-f0eaa5.o
  "___cxa_call_unexpected", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::close() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-f0eaa5.o
  "___cxa_end_catch", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::~basic_filebuf() in main-f0eaa5.o
  "___cxa_throw", referenced from:
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::sync() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::underflow() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::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<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-f0eaa5.o
      std::__1::basic_ifstream<char, std::__1::char_traits<char> >::~basic_ifstream() in main-f0eaa5.o
      std::__1::basic_filebuf<char, std::__1::char_traits<char> >::close() in main-f0eaa5.o
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-f0eaa5.o
      std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, 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)

1 个答案:

答案 0 :(得分:23)

gcc 是C代码的编译器 g ++ 是C ++代码的编译器。