I'm getting a strange error I suspect has to do with my system configuration. I am compiling/linking a trivial c++ program using g++ --version = g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
. The default language standard is documented to be c++98, yet even with the -std=c++98 option specified, I am seeing c++11 symbols in the output .o file. This is my test.cpp:
#include <string>
int main() {
std::string str = "Hello World!";
return 0;
}
Here are my compile and link commands (with presumably unnecessary explicit language standard option) and associated output:
$ g++ -c -Wall -std=c++98 -o test.o test.cpp
$ g++ -Wall -std=c++98 -o test test.o
$ nm -C test.o
U __gxx_personality_v0
0000000000000000 T main
U __stack_chk_fail
U _Unwind_Resume
U std::allocator<char>::allocator()
U std::allocator<char>::~allocator()
U std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
U std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
Notice the references to __cxx11::*
. I presume those are c++11 symbols that the compiler inserted. I get a successful build, but apparently using c++11. Here is the output from ldd:
$ ldd test
linux-vdso.so.1 => (0x00007ffc381f5000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f6548d48000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6548b32000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6548768000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f654845f000)
/lib64/ld-linux-x86-64.so.2 (0x000055785493c000)
For my real project, I have to link to third party libs that are c++98 but am unable to do so because of this compiler issue. My object files are looking for c++11 symbols in those libs but can't find them. Any insights?
Aucun commentaire:
Enregistrer un commentaire