我是靠谱客的博主 激动外套,最近开发中收集的这篇文章主要介绍移植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


最后

以上就是激动外套为你收集整理的移植Qt-4.8.5出现undefined reference to '__sync_sub_and_fetch_4'解决方法的全部内容,希望文章能够帮你解决移植Qt-4.8.5出现undefined reference to '__sync_sub_and_fetch_4'解决方法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(37)

评论列表共有 0 条评论

立即
投稿
返回
顶部