0

I am cross compiling a small c++ script for Windows on Linux.

It's made with Qt and uses curl, I compiled qt and curl via mxe (make qt5 and make curl).

I then run these commands:

  1. $MXE/usr/i686-w64-mingw32.static/qt5/bin/qmake
  2. make

Which gives me these errors:

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'

When I compile it for Linux, there are no errors.

Here is my .pro file:

QT += core
QT -= gui
QT += network

CONFIG += c++11

TARGET = add_feeds
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

LIBS += -lcurl

Any help appreciated.

If you need any other info, feel free to ask.

EDIT:

Output of 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
Rikudou_Sennin
  • 1,357
  • 10
  • 27
  • Try running with `make VERBOSE=1`, it will show you the command-line actually used to compile and link. My best guess is that you are not linking with `curl` on windows. – Max Value Apr 27 '16 at 12:04
  • Try specifying libcurl path in LIBS section using -L. – rakib_ Apr 27 '16 at 12:09
  • Possible duplicate of [Linking libCurl in QT gives a huge list of errors C++](http://stackoverflow.com/questions/8965631/linking-libcurl-in-qt-gives-a-huge-list-of-errors-c) – demonplus Apr 27 '16 at 12:10
  • Max Value: Added output to question. – Rikudou_Sennin Apr 27 '16 at 12:19
  • rakib: tried -L/root/compile/mxe/usr/i686-w64-mingw32.static/lib/libcurl.la, -L/root/compile/mxe/usr/i686-w64-mingw32.static/lib/libcurl.a and -L/root/compile/mxe/usr/i686-w64-mingw32.static/lib - none worked – Rikudou_Sennin Apr 27 '16 at 12:19
  • demonplus: not really duplicate, the problem here is with cross compiling, I'm not on Windows – Rikudou_Sennin Apr 27 '16 at 12:20
  • Make sure `-lcurl` is at end, from compilation log it's reffered even before the path is specified i.e. where -lpc is specified. – rakib_ Apr 27 '16 at 12:39
  • @Rikudou_Sennin g++ is sensitive about the order of linking. So try to run the link line by itself (copy it from the output of `make VERBOSE=1`, it is the `g++ -Wl,-s....`) and move `-lcurl` to the end of the line. See if that helps – Max Value Apr 27 '16 at 12:50

1 Answers1

0

This problem comes from QT, when static compiling it. Which QT Version do you have?QT Static compile bug report with Qt 5.13.0 I filed this bug report which had similar call to requqested functions.

Sherif O.
  • 506
  • 4
  • 15