• 3659阅读
  • 1回复

[讨论]编绎在ARM上运行的QT应用程序出错,谁能帮帮我 [复制链接]

上一主题 下一主题
 

只看楼主 倒序阅读 楼主  发表于: 2015-05-01
我在ubuntu上用ARM-linux-gcc重新编绎了QT,在Trolltech下生成QtEmbedded-4.8.6-arm目录,添加环境变量后qmake -v
root@ubuntu  :/home/shiyu/qtex1# qmake -v
QMake version 2.01a
Using Qt version 4.8.6 in /usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib

使用了新的qmake
然后我写了个hello.cpp用新的qmake编绎,make里就出现了下面的错误
root@ubuntu  :/home/shiyu/qtex1# make
arm-linux-gnueabihf-g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/QtEmbedded-4.8.6-arm/mkspecs/qws/arm-linux-gnueabihf-g++ -I. -I/usr/local/Trolltech/QtEmbedded-4.8.6-arm/include/QtCore -I/usr/local/Trolltech/QtEmbedded-4.8.6-arm/include/QtNetwork -I/usr/local/Trolltech/QtEmbedded-4.8.6-arm/include/QtGui -I/usr/local/Trolltech/QtEmbedded-4.8.6-arm/include -I. -I. -o hello.o hello.cpp
hello.cpp:4:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
hello.cpp:4:5: warning: unused parameter ‘argv’ [-Wunused-parameter]
arm-linux-gnueabihf-g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib -o hello hello.o    -L/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib -lQtGui -L/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib -lQtNetwork -lQtCore -lpthread
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib/libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()'
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib/libQtCore.so: undefined reference to `clock_gettime'
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib/libQtCore.so: undefined reference to `QDnotifyFileSystemWatcherEngine::create()'
collect2: error: ld returned 1 exit status
make: *** [hello] 错误 1

找了好久都没解决方法,那位大神遇到过这个问题啊?
本帖提到的人: @ubuntu
离线sharkoasis

只看该作者 1楼 发表于: 2015-05-02
QT编译出错解决
[size=xx-large]可能出错1:
libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()'

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

eg:
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'

resolution:



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:

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下是否有效,如果出错最好拿一份新的源码再去编译,之前就是因为没有换而浪费了很多时间。
快速回复
限100 字节
 
上一个 下一个