错误libc ++。所以:未定义引用`_Unwind_GetRegionStart'

时间:2017-05-14 22:01:20

标签: c++ ld clang++

我试图用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. 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;
}

我使用clang++-4.0进行编译,并以ld方式链接:

clang++-4.0 -c main.cpp -o main.o
ld -o test main.o -lc++ -lc++abi -lc

好像我错过了与另一个图书馆的链接,但我不知道哪一个或哪一个。

你看到错误或遗失的是什么?我想我在linux上用clang++做了一些c ++的东西,我缺少一些初学者的东西。

编译错误:

  

ld:警告:找不到条目符号_start;默认为   0000000000400380 main.o:在函数__cxx_global_var_init': main.cpp:(.text.startup+0x13): undefined reference to std :: ios_base :: Init :: Init()&#39; main.cpp :(。text.startup + 0x19):undefined   参考std::ios_base::Init::~Init()' main.cpp:(.text.startup+0x2d): undefined reference to __ dso_handle&#39;   //usr/lib/x86_64-linux-gnu/libc++.so:未定义引用   _Unwind_GetRegionStart' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to _ Unwind_RaiseException&#39;   //usr/lib/x86_64-linux-gnu/libc++.so:未定义引用   _Unwind_SetIP' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to _ Unwind_GetLanguageSpecificData&#39;   //usr/lib/x86_64-linux-gnu/libc++.so:未定义引用   _Unwind_Resume' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to _ Unwind_GetIP&#39; //usr/lib/x86_64-linux-gnu/libc++.so:   对_Unwind_SetGR' //usr/lib/x86_64-linux-gnu/libc++.so: undefined reference to _ Unwind_DeleteException&#39;

的未定义引用

1 个答案:

答案 0 :(得分:1)

您不应将C ++应用程序与Array ( [0] => Array ( [id] => 1 [farmer_name] => Mehul [mobile] => 8401036474 [address] => Karanagar road [village] => Nagarvel [total_acre] => 100 [state_id] => 1 [district_id] => 10 [taluka_id] => 28 [sales_id] => 43 [created_at] => 2017-05-15 04:21:09 [state_name] => gujarat [district_name] => bharuch [taluka_name] => anklesvar [crops] => Array ( [0] => Array ( [crop_id] => 4 [acres] => 15 [crop_name] => green gram [crops_images] => 1494836337726.jpg,1494739175265.jpg ) [1] => Array ( [crop_id] => 3 [acres] => 70 [crop_name] => rice [crops_images] => 1494836356691.jpg ) ) ) ) 链接。与C ++编译器可执行文件链接,因为它链接在所有必需的库中:

ld