How to resolve missing characters 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 character 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

A simple program communicates perfectly with g ++ without any additional arguments. Any ideas what I can do to get this program to bind or explain why this is not possible (if so)?

+3
source share
1 answer

Try:

$ clang++ test.cpp

If this does not do the trick, show the command line you are using.

+8
source

Source: https://habr.com/ru/post/1787596/


All Articles