Reputation: 3921
The following code, compiled on OS X with clang 2.8 from macports gives the missing symbol errors below.
#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. 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)?
Upvotes: 3
Views: 1093
Reputation: 218750
Try:
$ clang++ test.cpp
If that doesn't do the trick, show the command line you're using.
Upvotes: 8