移植Qt-4.8.5出现undefined reference to '__sync_sub_and_fetch_4'解决方法--转载

想要把Qt-4.8.5移植到s3c2440开发板,编译器为arm-linux-gcc 4.3.3,在编译过程中出现:

obj/release/JSClassRef.o: In function `OpaqueJSClassContextData::~OpaqueJSClassContextData()':
JSClassRef.cpp:(.text+0x5dc): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o: In function `OpaqueJSClassContextData::~OpaqueJSClassContextData()':
JSClassRef.cpp:(.text+0x7e8): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o: In function `OpaqueJSClass::create(JSClassDefinition const*)':
JSClassRef.cpp:(.text+0xb28): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o: In function `OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass*)':
JSClassRef.cpp:(.text+0xdfc): undefined reference to `__sync_add_and_fetch_4'
obj/release/JSClassRef.o: In function `OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass*)':
JSClassRef.cpp:(.text+0x1364): undefined reference to `__sync_add_and_fetch_4'
obj/release/JSClassRef.o: In function `QTWTF::ThreadSafeShared<OpaqueJSString>::deref()':
JSClassRef.cpp:(.text._ZN5QTWTF16ThreadSafeSharedI14OpaqueJSStringE5derefEv[QTWTF::ThreadSafeShared<OpaqueJSString>::deref()]+0xc): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o: In function `QTWTF::ThreadSafeShared<OpaqueJSClass>::deref()':
JSClassRef.cpp:(.text._ZN5QTWTF16ThreadSafeSharedI13OpaqueJSClassE5derefEv[QTWTF::ThreadSafeShared<OpaqueJSClass>::deref()]+0xc): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o: In function `QTJSC::JSCallbackObject<QTJSC::JSObject>::staticValueGetter(QTJSC::ExecState*, QTJSC::Identifier const&, QTJSC::PropertySlot const&)':
JSClassRef.cpp:(.text._ZN5QTJSC16JSCallbackObjectINS_8JSObjectEE17staticValueGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE[QTJSC::JSCallbackObject<QTJSC::JSObject>::staticValueGetter(QTJSC::ExecState*, QTJSC::Identifier const&, QTJSC::PropertySlot const&)]+0x160): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o: In function `QTJSC::JSCallbackObject<QTJSC::JSObject>::deleteProperty(QTJSC::ExecState*, QTJSC::Identifier const&)':
JSClassRef.cpp:(.text._ZN5QTJSC16JSCallbackObjectINS_8JSObjectEE14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE[QTJSC::JSCallbackObject<QTJSC::JSObject>::deleteProperty(QTJSC::ExecState*, QTJSC::Identifier const&)]+0x388): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o: In function `QTJSC::JSCallbackObject<QTJSC::JSObject>::callbackGetter(QTJSC::ExecState*, QTJSC::Identifier const&, QTJSC::PropertySlot const&)':
JSClassRef.cpp:(.text._ZN5QTJSC16JSCallbackObjectINS_8JSObjectEE14callbackGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE[QTJSC::JSCallbackObject<QTJSC::JSObject>::callbackGetter(QTJSC::ExecState*, QTJSC::Identifier const&, QTJSC::PropertySlot const&)]+0x2ec): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSClassRef.o:JSClassRef.cpp:(.text._ZN5QTJSC16JSCallbackObjectINS_8JSObjectEE3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE[QTJSC::JSCallbackObject<QTJSC::JSObject>::put(QTJSC::ExecState*, QTJSC::Identifier const&, QTJSC::JSValue, QTJSC::PutPropertySlot&)]+0x6ac): more undefined references to `__sync_sub_and_fetch_4' follow
obj/release/JSObjectRef.o: In function `JSClassRetain':
JSObjectRef.cpp:(.text+0x220): undefined reference to `__sync_add_and_fetch_4'
obj/release/JSObjectRef.o: In function `JSClassRelease':
JSObjectRef.cpp:(.text+0x288): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSObjectRef.o: In function `JSObjectMake':
JSObjectRef.cpp:(.text+0x33d4): undefined reference to `__sync_add_and_fetch_4'
obj/release/JSStringRef.o: In function `JSStringRetain':
JSStringRef.cpp:(.text+0x114): undefined reference to `__sync_add_and_fetch_4'
obj/release/JSStringRef.o: In function `JSStringRelease':
JSStringRef.cpp:(.text+0x308): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSStringRef.o: In function `JSStringIsEqualToUTF8CString':
JSStringRef.cpp:(.text+0x368): undefined reference to `__sync_sub_and_fetch_4'
obj/release/JSValueRef.o: In function `JSValueToStringCopy':
JSValueRef.cpp:(.text+0x2518): undefined reference to `__sync_sub_and_fetch_4'
obj/release/UStringImpl.o: In function `QTWTF::CrossThreadRefCounted<QTWTF::OwnFastMallocPtr<unsigned short> >::deref()':
UStringImpl.cpp:(.text._ZN5QTWTF21CrossThreadRefCountedINS_16OwnFastMallocPtrItEEE5derefEv[QTWTF::CrossThreadRefCounted<QTWTF::OwnFastMallocPtr<unsigned short> >::deref()]+0x30): undefined reference to `__sync_sub_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: *** [../../lib/libQtScript.so.4.8.6] Error 1
make[1]: Leaving directory `/opt/EmbedSky/Qt/qt-everywhere-opensource-src-4.8.6/src/script'
make: *** [sub-script-make_default-ordered] Error 2


google了好久终于找到了解决方法:

1.下载gcc源码:我用的4.4.3的(4.7的貌似用不成),解压,在gcc-4.4.3/gcc/config/arm/目录下找到一个linux-atomic.c;

2.制作链接库:使用libtool制作,输入命令

 libtool --tag=CC --mode=compile arm-linux-gcc -g -O2 -MT linux-atomic.lo -MD -MP -MF linux-atomic.Tpo -c -o linux-atomic.lo linux-atomic.c 

然后:

 libtool --tag=CC --mode=link arm-linux-g++ -g -O2 -o liblinux-atomic.la linux-atomic.lo

这一步会在当前目录生成.libs目录;

3.将生成的库拷贝到一个比较短的目录,比如/opt:

cp .libs/liblinux-atomic.a /opt

4.修改Qt的Makefile:

进入Qt源码目录:

cd qt-everywhere-opensource-src-4.8.6

然后:

vim src/script/Makefile

修改:

在LIBS  = 。。。。。。。。。。。。。的结尾添加 -L/opt -llinux-atomic

保存,继续make,就OK了。


参考:http://blog.csdn.net/zpzkitt/article/details/8970626

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值