简体   繁体   English

在Mac OS X 10.6上使用clang 2.8编译C ++代码时,如何解决缺失的符号?

[英]How can I resolve missing symbols when compiling C++ code with clang 2.8 on Mac OS X 10.6?

The following code, compiled on OS X with clang 2.8 from macports gives the missing symbol errors below. 以下代码在OS X上使用来自macports的clang 2.8编译,在下面给出了缺少的符号错误。

   #include <iostream>

   int main()
   {
     std::cout << "hello world" << std::endl;
   }


jonathancoe@MacBookCoe:/tmp$ clang HW.cpp 
Undefined symbols:
  "__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc", referenced from:
      _main in cc-C9ObsA.o
  "__ZNSt8ios_base4InitC1Ev", referenced from:
      ___cxx_global_var_init in cc-C9ObsA.o
  "__ZNSt8ios_base4InitD1Ev", referenced from:
      ___cxx_global_var_init in cc-C9ObsA.o
  "__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_", referenced from:
      _main in cc-C9ObsA.o
  "__ZNSolsEPFRSoS_E", referenced from:
      _main in cc-C9ObsA.o
  "__ZSt4cout", referenced from:
      _main in cc-C9ObsA.o
ld: symbol(s) not found

The simple program links fine using g++ without any extra arguments. 简单的程序使用g ++很好地链接,没有任何额外的参数。 Any ideas what I can do to get this program to link or explanations as to why it is not possible (if that is the case)? 任何想法,我可以做什么来得到这个程序链接或解释为什么不可能(如果是这种情况)?

Try: 尝试:

$ clang++ test.cpp

If that doesn't do the trick, show the command line you're using. 如果这不起作用,请显示您正在使用的命令行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM