qt交叉编译常见问题及解决方法

问题:  libQtCore.so: undefined reference to `clock_gettime'
分析: 应该是找不到库文件  librt.so ( POSIX.1b Realtime Extensions library
解决: 
    办法一: 重新编译qt4.5
                  在./configure后 添加参数 -lrt 
                  我用的是天嵌embeded,修改arm_qt4.5_build,如下:
echo yes | ../../qt-embedded-linux-opensource-src-4.5.0/configure -prefix /opt/EmbedSky/qt-4.5/__install/arm/ -release -shared -fast -no-largefile -qt-sql-sqlite -no-qt3support -no-xmlpatterns -no-mmx -no-3dnow -no-sse -no-sse2 -no-svg -no-webkit -qt-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libjpeg -make libs -nomake examples -nomake docs -nomake demo -no-nis -no-cups -no-iconv -no-dbus -no-openssl -xplatform qws/linux-arm-g++ -embedded arm -little-endian -qt-freetype -depths 16 -qt-gfx-linuxfb -qt-gfx-transformed -qt-gfx-multiscreen -no-gfx-vnc -no-gfx-qvfb -qt-kbd-usb -no-glib -armfpa -no-mouse-tslib -I/tslib-1.4/inclued -L/tslib-1.4/lib -lrt &&

    办法二: 修改Makefile
                  在makefile中找的   LIBS    ,在其后添加 -lrt

可能出错1:


libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()'

解决办法:
vi ./src/corelib/io/io.pri
find linux-*:
append your cross-toolchain's prefix after it

举例:
my toolchains's prefix is arm_xxxxx
so....
68        linux-*|arm-linux-*:{            //该行改为
69             SOURCES += \
70                     io/qfilesystemwatcher_inotify.cpp \
71                     io/qfilesystemwatcher_dnotify.cpp
72 
73             HEADERS += \
74                     io/qfilesystemwatcher_inotify_p.h \
75                     io/qfilesystemwatcher_dnotify_p.h
76         }
注意:更改后,要重新编译QT



可能出错2:


libQtCore.so: undefined reference to `clock_gettime'

解决办法:
LFLAGS 编译选项中添加 -lrt
append "-lrt" parameters after the "./configure" so that the compiler can find the define in librt.

 


可能出错3:
{standard input}: Assembler messages:

{standard input}:778: Error: register or shift expression expected -- `orr r3,r2,lsl#16'

{standard input}:789: Error: register or shift expression expected -- `orr r2,r3,lsl#16'

{standard input}:7748: Error: register or shift expression expected -- `orr r3,r0,lsl#16'

{standard input}:7761: Error: register or shift expression expected -- `orr r1,r0,lsl#16'

make[1]: *** [.obj/release-shared-emb-arm/qfontengine_ft.o] Error 1

make[1]: Leaving directory `/home/lijian/QT/build/3.4.1gcc/qt-embedded-4.6.2/src/gui'

make: *** [sub-gui-make_default-ordered] Error 2

解决办法:

To fix this issue patch /src/3rdparty/freetype/include/freetype/config/ftconfig.h Line 330.

"orr %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */

to "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */

PS: 都说是交叉编译器版本问题,用4.5.1就好了... 没试过...



可能出错4:

In file included from ./config.h:26,

from ../JavaScriptCore/pcre/pcre_compile.cpp:44:

../JavaScriptCore/wtf/Platform.h:338:6: #error "Not supported ARM architecture"

make[1]: *** [obj/release/pcre_compile.o] Error 1

make[1]: Leaving directory `/usr/local/qte4.6-arm/src/3rdparty/webkit/WebCore'

make: *** [sub-webkit-make_default-ordered] Error 2

解决办法:

在参数上加 -D__ARM_ARCH_5TEJ__ 或者 -D__ARM_ARCH_4T

或者修改src/3rdparty/webkit/WebCore/Makefile,在cflags中加入-D__ARM_ARCH_4T__ 修改src/script/Makefile,同上

 


可能出错5:

./configure中选中的是-xplatform qws/linux-arm-g++, 但是在编译时,却采用的x86-g++,

刚开始编译时,是采用的主机的g++,后面编译时才是调用的linux-arm-g++,这里并没有出错,请耐心等待。


可能出错5:

warning: libts-0.0.so.0, needed by , not found (try using -rpath or -rpath-link)

undefined reference to `ts_read_raw'

undefined reference to `ts_open'

undefined reference to `ts_fd'

undefined reference to `ts_config'

undefined reference to `ts_close'

undefined reference to `ts_read'

collect2: ld returned 1 exit status

解决办法:

修改qt-everywhere-opensource-src-4.6.0/mkspecs/qws/linux-arm-g++/qmake.conf 文件(添加lts参数):

QMAKE_CC                = arm-linux-gcc -lts

QMAKE_CXX               = arm-linux-g++ -lts

QMAKE_LINK              = arm-linux-g++ -lts

QMAKE_LINK_SHLIB        = arm-linux-g++ -lts

还有个错误是加了-pch 参数引起的,具体错误内容忘了。

另外一定要在编译之前确认arm-linux-gcc等环境在当前shell下是否有效,如果出错最好拿一份新的源码再去编译,之前就是因为没有换而浪费了很多时间。

  1. ../../include/QtCore/../../src/corelib/arch/qatomic_armv5.h: Assembler messages:  
  2. ../../include/QtCore/../../src/corelib/arch/qatomic_armv5.h:131: Error: no such instruction: `swpb %cl,%dl,[%ebp]'  
  3. ../../include/QtCore/../../src/corelib/arch/qatomic_armv5.h:131: Error: no such instruction: `swpb %dl,%sil,[%ebp]'  
解决方法:
[html]  view plain copy
  1. inline char q_atomic_swp(volatile char *ptr, char newval)  
  2. {  
  3.     register char ret;  
  4. /*    asm volatile("swpb %0,%2,[%3]"  
  5.                  : "=&r"(ret), "=m" (*ptr)  
  6.                  : "r"(newval), "r"(ptr)  
  7.                  : "cc", "memory");  
  8. */  
  9.     ret=*ptr;  
  10.     *ptr=newval;  
  11.   
  12.     return ret;  
  13. }  
  14.   
  15. 和  
  16.   
  17. inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)  
  18. {  
  19.     int originalValue;  
  20. #ifndef QT_NO_ARM_EABI  
  21. /*    asm volatile("swp %0,%2,[%3]"  
  22.                  : "=&r"(originalValue), "=m" (_q_value)  
  23.                  : "r"(newValue), "r"(&_q_value)  
  24.                  : "cc", "memory");  
  25. */  
  26.      originalValue=_q_value;  
  27.      _q_value=newValue
  28. 以上内容转载自  http://blog.chinaunix.net/uid-29513507-id-4234035.ht

你可能感兴趣的:(QT,嵌入式开发,linux)