undefined reference to `__atomic_fetch_add_4'

在Fedora17 i386平台(gcc4.7),使用rpm打包发现一个问题,so文件不包含__atomic_fetch_add_4的符号定义,类似
src/foo/.libs/libfoo.so: undefined reference to `__atomic_fetch_add_4'
提示缺失的符号定义,但是实际上我们已经做了链接,是什么情况导致这个现象呢?通过调试发现在configure之前,rpmbuild做了以下事情:
+ CFLAGS='-O2 -g -march=i386 -mtune=i686'
+ export CFLAGS
+ CXXFLAGS='-O2 -g -march=i386 -mtune=i686'
+ export CXXFLAGS
+ FFLAGS='-O2 -g -march=i386 -mtune=i686'
+ export FFLAGS
定义了build的一系列环境变量,而这个是导致缺失符号定义的最终祸首,具体说是C++标准有变化,C++0x11旧的标准和新标准存在着不一致导致,详情可见http://redmine.openrtm.org/issues/2453,解决办法也很简单,在spec文件的%build段,修改
%configure

%configure CFLAGS="-g -O2" CXXFLAGS="-g -O2"
即可。

Monthly Archives

Pages

Powered by Movable Type 7.7.2

About this Entry

This page contains a single entry by Cnangel published on July 20, 2012 5:56 PM.

openssh and X11 forwarding was the previous entry in this blog.

log4cpp 1.1.0 patch is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.