I have this small code example :
#include <string>
int main()
{
std::string s("12");
return 0;
}
when I compile it with GCC ( gcc main.cpp )I get the following linking error:
/depot/tool/201512/64/gcc/v9.3.0/bin/../lib/gcc/x86_64-redhat-linux/9.3.0/../../../../x86_64-redhat-linux/bin/ld: /tmp/ccwSdH4J.o: in function main': main.cpp:(.text+0x11): undefined reference to
std::allocator::allocator()'
/depot/tool/201512/64/gcc/v9.3.0/bin/../lib/gcc/x86_64-redhat-linux/9.3.0/../../../../x86_64-redhat-linux/bin/ld: main.cpp:(.text+0x26): undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' /depot/tool/201512/64/gcc/v9.3.0/bin/../lib/gcc/x86_64-redhat-linux/9.3.0/../../../../x86_64-redhat-linux/bin/ld: main.cpp:(.text+0x32): undefined reference to
std::allocator::~allocator()'
/depot/tool/201512/64/gcc/v9.3.0/bin/../lib/gcc/x86_64-redhat-linux/9.3.0/../../../../x86_64-redhat-linux/bin/ld: main.cpp:(.text+0x43): undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /depot/tool/201512/64/gcc/v9.3.0/bin/../lib/gcc/x86_64-redhat-linux/9.3.0/../../../../x86_64-redhat-linux/bin/ld: main.cpp:(.text+0x56): undefined reference to
std::allocator::~allocator()'
/depot/tool/201512/64/gcc/v9.3.0/bin/../lib/gcc/x86_64-redhat-linux/9.3.0/../../../../x86_64-redhat-linux/bin/ld: /tmp/ccwSdH4J.o:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
how to solve the issue ? do I need extra switched for compilation?
many thanks.
expecting a passing compilation.