简体   繁体   中英

Hundreds of “undefined reference” errors when linking Qt application

I am trying to cross-compile a Qt application for Windows using mingw-w64 on Linux. Everything compiles smoothly until the linking stage; I'm getting hundreds of "undefined reference" errors having to do with Qt libraries. Here is a sample: http://pastebin.com/b20Ede7a

Here's my .pro file:

TEMPLATE = app
TARGET = myApp
DEPENDPATH += . res src

QT += core gui
CONFIG += static

isEmpty(TTS_ENGINE) {
    TTS_ENGINE = flite
}

QMAKE_CXX = i686-w64-mingw32.static-g++
QMAKE_LD = i686-w64-mingw32.static-ld
QMAKE_CXXFLAGS += -std=c++0x -ggdb -DWINDOWS
QMAKE_LIBDIR += /opt/mxe/usr/i686-w64-mingw32.static/qt/lib /opt/mxe/usr/i686-w64-mingw32.static/lib
QMAKE_LIBS += -lSDL2_image -lSDL2_mixer -lpng -lz -ljpeg -lwebp -ltiff -lfreetype -lSDL2_ttf -llua `sdl2-config --libs` -lgif -lfontconfig -lm
INCLUDEPATH += . src /opt/mxe/usr/i686-w64-mingw32.static/qt/include /opt/mxe/usr/i686-w64-mingw32.static/include /opt/mxe/usr/i686-w64-mingw32.static/include/freetype2

# Input
HEADERS +=  bunch/of/headers
FORMS += res/desc.ui
RESOURCES += res/desc.res
SOURCES +=  bunch/of/sources

What could be the cause of this problem? I am using static Qt4 from MXE .

Edit: Also, here is the output of i686-w64-mingw32.static-g++ -v :

Using built-in specs.
COLLECT_GCC=/opt/mxe/usr/bin/i686-w64-mingw32.static-g++
COLLECT_LTO_WRAPPER=/opt/mxe/usr/libexec/gcc/i686-w64-mingw32.static/4.9.2/lto-wrapper
Target: i686-w64-mingw32.static
Configured with: /opt/mxe/tmp-gcc-i686-w64-mingw32.static/gcc-4.9.2/configure --target=i686-w64-mingw32.static --build=i686-pc-linux-gnu --prefix=/opt/mxe/usr --libdir=/opt/mxe/usr/lib --enable-languages=c,c++,objc,fortran --enable-version-specific-runtime-libs --with-gcc --with-gnu-ld --with-gnu-as --disable-nls --disable-shared --disable-multilib --without-x --disable-win32-registry --enable-threads=win32 --disable-libgomp --with-cloog=/opt/mxe/usr --with-gmp=/opt/mxe/usr --with-isl=/opt/mxe/usr --with-mpc=/opt/mxe/usr --with-mpfr=/opt/mxe/usr --with-as=/opt/mxe/usr/bin/i686-w64-mingw32.static-as --with-ld=/opt/mxe/usr/bin/i686-w64-mingw32.static-ld --with-nm=/opt/mxe/usr/bin/i686-w64-mingw32.static-nm
Thread model: win32
gcc version 4.9.2 (GCC) 

And the failing link command (sorry about the single line):

i686-w64-mingw32.static-g++ -Wl,-s -mthreads -Wl,-subsystem,windows -o release/descend.exe object_script.descend.Release  -L'/opt/mxe/usr/i686-w64-mingw32.static/qt/lib' -L'/opt/mxe/usr/i686-w64-mingw32.static/lib' -L'/opt/mxe/usr/i686-w64-mingw32.static/qt/lib' -lSDL2_image -lSDL2_mixer -lwebp -lfreetype -lSDL2_ttf -llua `sdl2-config --libs` -lgif -lfontconfig -lflite_cmu_us_kal -lflite_cmu_time_awb -lflite_cmu_us_kal16 -lflite_cmu_us_awb -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmu_indic_lang -lflite_cmu_grapheme_lang -lflite_cmulex -lflite_cmu_indic_lex -lflite_cmu_grapheme_lex -lflite -lmingw32 -lqtmain -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lmng -llcms2 -lm -ltiff -llzma -ljpeg -lQtCore -lpng -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz 

I think your libQtCore.a archive is compiled using a different version of g++. Currently it is trying to use it from the following path at the link step: /opt/mxe/usr/i686-w64-mingw32.static/qt/lib/libQtCore.a

If you do not mean to use this version, then specify the path to libQtCore.a at the link step (that is compiled using the same version of gcc).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM