错误 libc++.so:对“_Unwind_GetRegionStart”的未定义引用
Error libc++.so: undefined reference to `_Unwind_GetRegionStart'
我正在尝试用 clang++-4.0
编译我的第一个 C++ 胚胎
我的代码:
//main.cpp
#include <iostream>
// this line is to deal with the link error:
// "undefined reference to symbol '__cxa_thread_atexit@@CXXABI..."
// cf.
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;
}
我用 clang++-4.0
编译,link 用 ld
编译:
clang++-4.0 -c main.cpp -o main.o
ld -o test main.o -lc++ -lc++abi -lc
就好像我错过了 link 另一个图书馆,但我不知道是哪个图书馆。
你看到哪里出了问题或遗漏了什么吗?我想我在 linux.
上用 clang++
做 c++ 东西时缺少一些初学者的东西
编译错误:
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 to std::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'
你不应该 link C++ 应用程序 ld
。 Link 使用 C++ 编译器可执行文件,因为它 link 在所有必需的库中:
clang++-4.0 -c main.cpp -o main.o
clang++-4.0 -o test main.o
我正在尝试用 clang++-4.0
我的代码:
//main.cpp
#include <iostream>
// this line is to deal with the link error:
// "undefined reference to symbol '__cxa_thread_atexit@@CXXABI..."
// cf.
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;
}
我用 clang++-4.0
编译,link 用 ld
编译:
clang++-4.0 -c main.cpp -o main.o
ld -o test main.o -lc++ -lc++abi -lc
就好像我错过了 link 另一个图书馆,但我不知道是哪个图书馆。
你看到哪里出了问题或遗漏了什么吗?我想我在 linux.
上用clang++
做 c++ 东西时缺少一些初学者的东西
编译错误:
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'
你不应该 link C++ 应用程序 ld
。 Link 使用 C++ 编译器可执行文件,因为它 link 在所有必需的库中:
clang++-4.0 -c main.cpp -o main.o
clang++-4.0 -o test main.o