错误 undefined reference to __cxa_guard_acquire/release

Posted LarryKnight

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误 undefined reference to __cxa_guard_acquire/release相关的知识,希望对你有一定的参考价值。

用gcc编译 c++ 程序时,出现错误 undefined reference to __cxa_guard_acquire linker error, 但是用icc可以正常编译, 问题出在static 上。从网上搜到的解决办法是加库的链接:

To resolve this undefined references (__cxa_guard_acquire ) , add a library flag "-lstdc++" in your Makefile. It should work. It worked for me.
(http://rowley.zendesk.com/entries/46190-undefined-reference-to-cxa-guard-acquire-error-message)
加上后工作正常。

转自http://blog.sina.com.cn/s/blog_607233f50100xlml.html

 

在 gcc编译语句后添加-lstdc++即可。

如果出现其他未定义声明的情况:

undefined reference to `XXX‘
collect2: ld returned 1 exit status

同理添加-lxxx编译参数即可。

 

以上是关于错误 undefined reference to __cxa_guard_acquire/release的主要内容,如果未能解决你的问题,请参考以下文章

Android编译错误——undefined reference to

解决undefined reference to `__aeabi_uidivmod‘和undefined reference to `__aeabi_uidiv‘错误

错误 undefined reference to __cxa_guard_acquire/release

undefined reference to ceil 链接错误

undefined reference to异常怎么解决

Qt错误:error: undefined reference to `vtable for 类名'