c++ - Linker error with clang++ for some standard library classes -


i facing weird linker issue clang++ - able find definition of std::string class not of std::ios_base::failure class.

$ cat foo.cpp #include <string> #include <iostream>  int main() {    std::string msg = "hello world";    std::ios_base::failure f(msg);    std::cout << msg << std::endl;    return 0; }  $ clang++ foo.cpp /tmp/foo-b77625.o: in function `main': foo.cpp:(.text+0x4d): undefined reference `std::ios_base::failure::failure(std::__cxx11::basic_string<char,  std::char_traits<char>, std::allocator<char> > const&)' clang-3.7: error: linker command failed exit code 1 (use -v see  invocation)  $ clang++ --version clang version 3.7.0 (trunk 239466) target: x86_64-unknown-linux-gnu thread model: posix 

i noticed if comment instantiation of std::ios_base::failure, program links (and executes) correctly.

$ clang++ foo.cpp && ./a.out hello world 

can please me understand behavior , how fix it?

p.s. observed same behavior clang version 3.6.0 well.

assuming intent on using clang's own standard-library (libc++), not far off - have provide include-path of standard-library (where ever libcxx-build installed to):

$> clang++ foo.cpp -stdlib=libc++ -i/path/to/libcxx-build/include/c++/v1 

(add "-v" switch above, if want verbose output).

p.s. unless includes go elsewhere clang-3.7, above aught work - tested clang-3.8


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -