交叉编译链接器错误

时间:2016-04-27 11:58:51

标签: c++ qt curl static-linking mxe

我正在Linux上为Windows编译一个小的c ++脚本。

用Qt制作并使用curl,我通过mxe(make qt5make curl编译了qt和curl。

然后我运行这些命令:

  1. $MXE/usr/i686-w64-mingw32.static/qt5/bin/qmake
  2. make
  3. 这给了我这些错误:

    release/main.o:main.cpp:(.text.startup+0x4b7): undefined reference to `_imp__curl_easy_init'
    release/main.o:main.cpp:(.text.startup+0x6a8): undefined reference to `_imp__curl_easy_setopt'
    release/main.o:main.cpp:(.text.startup+0x781): undefined reference to `_imp__curl_easy_perform'
    release/main.o:main.cpp:(.text.startup+0x874): undefined reference to `_imp__curl_easy_cleanup'
    

    当我为Linux编译它时,没有错误。

    这是我的.pro文件:

    QT += core
    QT -= gui
    QT += network
    
    CONFIG += c++11
    
    TARGET = add_feeds
    CONFIG += console
    CONFIG -= app_bundle
    
    TEMPLATE = app
    
    SOURCES += main.cpp
    
    LIBS += -lcurl
    

    任何帮助表示感谢。

    如果您需要任何其他信息,请随时提出。

    编辑:

    make VERBOSE=1

    的输出
    make -f Makefile.Release
    make[1]: Entering directory `/root/compile/add_feeds'
    i686-w64-mingw32.static-g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=gnu++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I../mxe/usr/i686-w64-mingw32.static/qt5/include -I../mxe/usr/i686-w64-mingw32.static/qt5/include/QtNetwork -I../mxe/usr/i686-w64-mingw32.static/qt5/include/QtCore -Irelease -I../mxe/usr/i686-w64-mingw32.static/qt5/mkspecs/win32-g++  -o release/main.o main.cpp
    i686-w64-mingw32.static-g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=gnu++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I../mxe/usr/i686-w64-mingw32.static/qt5/include -I../mxe/usr/i686-w64-mingw32.static/qt5/include/QtNetwork -I../mxe/usr/i686-w64-mingw32.static/qt5/include/QtCore -Irelease -I../mxe/usr/i686-w64-mingw32.static/qt5/mkspecs/win32-g++  -o release/add_feeds_plugin_import.o add_feeds_plugin_import.cpp
    i686-w64-mingw32.static-g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release/add_feeds.exe release/main.o release/add_feeds_plugin_import.o  -lcurl -L/root/compile/mxe/usr/i686-w64-mingw32.static/qt5/lib -L/root/compile/mxe/usr/i686-w64-mingw32.static/qt5/plugins/bearer /root/compile/mxe/usr/i686-w64-mingw32.static/qt5/plugins/bearer/libqgenericbearer.a /root/compile/mxe/usr/i686-w64-mingw32.static/qt5/plugins/bearer/libqnativewifibearer.a /root/compile/mxe/usr/i686-w64-mingw32.static/qt5/lib/libQt5Network.a -ldnsapi -liphlpapi -lssl -lcrypto -lgdi32 -lcrypt32 /root/compile/mxe/usr/i686-w64-mingw32.static/qt5/lib/libQt5Core.a -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmpr -lz -lpcre16 
    release/main.o:main.cpp:(.text.startup+0x4b7): undefined reference to `_imp__curl_easy_init'
    release/main.o:main.cpp:(.text.startup+0x6a8): undefined reference to `_imp__curl_easy_setopt'
    release/main.o:main.cpp:(.text.startup+0x781): undefined reference to `_imp__curl_easy_perform'
    release/main.o:main.cpp:(.text.startup+0x874): undefined reference to `_imp__curl_easy_cleanup'
    collect2: error: ld returned 1 exit status
    make[1]: *** [release/add_feeds.exe] Error 1
    make[1]: Leaving directory `/root/compile/add_feeds'
    make: *** [release] Error 2
    

1 个答案:

答案 0 :(得分:0)

此问题来自静态编译时的QT。 您拥有哪个QT版本?QT Static compile bug report with Qt 5.13.0 我提交了此错误报告,该报告对要求的功能有类似的调用。