I'm trying to have my first embryo of C++ compiled with clang++-4.0
my code:
//main.cpp
#include <iostream>
// this line is to deal with the link error:
// "undefined reference to symbol '__cxa_thread_atexit@@CXXABI..."
// cf. http://stackoverflow.com/q/29322666/356440
extern "C" int __cxa_thread_atexit(void (*func)(), void *obj,
void *dso_symbol) {
int __cxa_thread_atexit_impl(void (*)(), void *, void *);
return __cxa_thread_atexit_impl(func, obj, dso_symbol);
}
int main ()
{
return 0;
}
and I compile with clang++-4.0
, and link with ld
this way:
clang++-4.0 -c main.cpp -o main.o
ld -o test main.o -lc++ -lc++abi -lc
It's as if I'm missing to link with another library, but I don't know which one or ones.
Do you see what's wrong or missing ? I think I'm missing some beginner stuff for doing c++ stuffs with clang++
on linux.
Compilation errors:
ld: warning: cannot find entry symbol _start; defaulting to 0000000000400380 main.o: In function
__cxx_global_var_init': main.cpp:(.text.startup+0x13): undefined reference to
std::ios_base::Init::Init()' main.cpp:(.text.startup+0x19): undefined reference tostd::ios_base::Init::~Init()' main.cpp:(.text.startup+0x2d): undefined reference to
__dso_handle' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to_Unwind_GetRegionStart' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_RaiseException' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to_Unwind_SetIP' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_GetLanguageSpecificData' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to_Unwind_Resume' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_GetIP' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to_Unwind_SetGR' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to
_Unwind_DeleteException'