QT creator with mingw, glew linking errors - c++

I've been trying for around 3/4 days to link glew with qt creator, but I´m unable to.
I've tried with msvc and mingw 64 & 32 bits.
Right now I´m using mingw 32 bits, and also a 32bits glew compiled with mingw.
This is the code in my .pro file:
QT += core gui opengl
CONFIG += c++11
INCLUDEPATH += C:/lib/glew-gcc-debug-1.10.0-win32/include/GL
LIBS += -lglew32.dll -LC:/lib/glew-gcc-debug-1.10.0-win32/bin -LC:/lib/glew-gcc-debug-1.10.0-win32/lib
TARGET = Test
TEMPLATE = app
SOURCES += \
glslprogram.cpp \
glutils.cpp \
main.cpp \
mainview.cpp \
mainwindow.cpp \
sceneLine.cpp \
dialog.cpp \
viewpositiondialog.cpp
HEADERS += \
glslprogram.h \
glutils.h \
mainview.h \
scene.h \
mainwindow.h \
sceneLine.h \
dialog.h \
viewpositiondialog.h
FORMS += \
dialog.ui \
viewpositiondialog.ui
OTHER_FILES += \
shader/scenebasic2.dat
and this is is the output:
g++ -Wl,-subsystem,windows -mthreads -o debug\Test.exe object_script.Test.Debug -lmingw32 -LC:/Qt/Qt5.5.0/5.5/mingw492_32/lib -lqtmaind -lshell32 -lglew32.dll -LC:/lib/glew-gcc-debug-1.10.0-win32/bin -LC:/lib/glew-gcc-debug-1.10.0-win32/lib -lQt5OpenGLd -lQt5Widgetsd -lQt5Guid -lQt5Cored
./debug\glutils.o: In function `ZN7GLUtils19checkForOpenGLErrorEv':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:34: undefined reference to `glGetError#0'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:39: undefined reference to `glGetError#0'
Makefile.Debug:112: recipe for target 'debug\Test.exe' failed
./debug\glutils.o: In function `ZN7GLUtils10dumpGLInfoEb':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:46: undefined reference to `glGetString#4'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:47: undefined reference to `glGetString#4'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:48: undefined reference to `glGetString#4'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:49: undefined reference to `glGetString#4'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:52: undefined reference to `glGetIntegerv#8'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:53: undefined reference to `glGetIntegerv#8'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/glutils.cpp:63: undefined reference to `glGetIntegerv#8'
./debug\mainview.o: In function `ZN8MainView12initializeGLEv':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/mainview.cpp:113: undefined reference to `glClearColor#16'
./debug\sceneLine.o: In function `ZN9SceneLine9initSceneEv':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:279: undefined reference to `glClearColor#16'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:280: undefined reference to `glEnable#4'
./debug\sceneLine.o: In function `ZN9SceneLine6renderEPf':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:325: undefined reference to `glClear#4'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:336: undefined reference to `glDrawArrays#12'
./debug\sceneLine.o: In function `ZN9SceneLine6renderEdPf':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:350: undefined reference to `glClear#4'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:360: undefined reference to `glDrawArrays#12'
./debug\sceneLine.o: In function `ZN9SceneLine6renderEddddddPf':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:393: undefined reference to `glClear#4'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:417: undefined reference to `glDrawArrays#12'
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:421: undefined reference to `glDrawArrays#12'
./debug\sceneLine.o: In function `ZN9SceneLine6resizeEii':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/sceneLine.cpp:441: undefined reference to `glViewport#16'
./debug\sceneLine.o: In function `ZN5SceneC2Ev':
C:\Development\test\build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../Test/scene.h:4: undefined reference to `vtable for Scene'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: Leaving directory 'C:/Development/test/build-Test-Desktop_Qt_5_5_0_MinGW_32bit-Debug'
makefile:34: recipe for target 'debug' failed
Hope someone can help.

Related

uwebsockets failed to start: libuv.c:-1: error: undefined reference to `uv_is_closing'

My project has linked uwebsockets.
linked libs:
C:/Users/Sunway/.conan/data/zlib/1.2.11/_/_/package/a955db98e980a5ab86ae50d6df8bfee361185c27/lib/libzlib.a;
C:/Users/Sunway/.conan/data/libuv/1.41.0/_/_/package/a955db98e980a5ab86ae50d6df8bfee361185c27/lib/libuv_a.a;
C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a;
iphlpapi.dll;psapi.dll;userenv.dll;ws2_32.dll
main.cpp
#include "main.h"
int main()
{
uWS::App().get("/hello", [](auto *res, auto *req) {
res->end("Hello");
});
std::cout << "exiting now!" << std::endl;
return 0;
}
I got errors
libuv.c:-1: error: undefined reference to `uv_is_closing'
libuv.c:-1: error: undefined reference to `uv_poll_init_socket'
……
35 functions was undefined, but I cant call these functions in my main.cpp directly.
os: Windows10 x64
IDE: QtCreator4.14.2
compiler: MinGW 32-bit
full of the error log
11:04:53: 为项目rfid-cmd执行步骤 ... 11:04:53: 正在启动
"C:\Qt\Tools\CMake_64\bin\cmake.exe" --build . --target all
[1/1 0.3/sec] Linking CXX executable rfid-cmd.exe FAILED: rfid-cmd.exe
cmd.exe /C "cd . && C:\Qt\Tools\mingw810_32\bin\g++.exe -g
CMakeFiles/rfid-cmd.dir/main.cpp.obj -o rfid-cmd.exe
-Wl,--out-implib,librfid-cmd.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -LD:/Project/misc/qt/rfid-cmd/lib -LD:/Project/misc/qt/rfid-cmd/lib/NFC9 -lReader -lEasyUSB214x C:/Users/Sunway/.conan/data/zlib/1.2.11///package/a955db98e980a5ab86ae50d6df8bfee361185c27/lib/libzlib.a
C:/Users/Sunway/.conan/data/libuv/1.41.0///package/a955db98e980a5ab86ae50d6df8bfee361185c27/lib/libuv_a.a C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a -liphlpapi -lpsapi -luserenv -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0xce):
undefined reference to uv_is_closing' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x143): undefined reference to uv_poll_init_socket'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x1ee):
undefined reference to uv_poll_stop' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x2c9): undefined reference to uv_prepare_init'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x2dc):
undefined reference to uv_prepare_start' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x2e7): undefined reference to uv_unref'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x30a):
undefined reference to uv_check_init' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x315): undefined reference to uv_unref'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x328):
undefined reference to uv_check_start' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x371): undefined reference to uv_loop_new'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x38f):
undefined reference to uv_ref' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x39a): undefined reference to uv_prepare_stop'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x3af):
undefined reference to uv_close' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x3ba): undefined reference to uv_ref'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x3c5):
undefined reference to uv_check_stop' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x3da): undefined reference to uv_close'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x40f):
undefined reference to uv_run' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x41a): undefined reference to uv_loop_delete'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x44f):
undefined reference to uv_run' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x4f3): undefined reference to uv_timer_init'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x514):
undefined reference to uv_unref' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x550): undefined reference to uv_ref'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x558):
undefined reference to uv_timer_stop' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x56b): undefined reference to uv_close'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x5d2):
undefined reference to uv_timer_start' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x620): undefined reference to uv_ref'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x633):
undefined reference to uv_close' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x669): undefined reference to uv_async_init'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x671):
undefined reference to uv_unref' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x15f): undefined reference to uv_poll_start'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x1cf):
undefined reference to uv_poll_start' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x20b): undefined reference to uv_close'
C:/Users/Sunway/.conan/data/usockets/0.7.1///package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x5a7):
undefined reference to uv_timer_stop' C:/Users/Sunway/.conan/data/usockets/0.7.1/_/_/package/c8f7ac6f549a378a4f5ea4f08b4f33a70398fa20/lib/libuSockets.a(libuv.o):libuv.c:(.text+0x686): undefined reference to uv_async_send' collect2.exe: error: ld
returned 1 exit status ninja: build stopped: subcommand failed.
11:04:58: 进程"C:\Qt\Tools\CMake_64\bin\cmake.exe"退出,退出代码 1 。 Error
while building/deploying project rfid-cmd (kit: Desktop Qt 5.15.2
MinGW 32-bit) When executing step "Build" 11:04:58: Elapsed time:
00:05.
Is there any linking sequence problem? I see that usockets links behind libuv, maybe we can try swap the sequence: to link usockets first.
You are using static linkage, and usockets depends on libuv, so swap the sequence will fix the problem.
Related questions:
Why does the order in which libraries are linked sometimes cause errors in GCC?

Linking an external library with cmake

When I am linking to an external library, I get a lot of "undefined reference", despite those functions are in the external library.
$ g++.exe -std=c++11 -g2 -O0 -Wall -Wextra -pedantic -g -Wl,--whole-archive E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a -Wl,--no-whole-archive -o buergerkarte.exe -Wl,--major-image-version,0,--minor-image-version,0 E:/msys64/mingw64/lib/libQt5Widgetsd.dll.a E:/msys64/usr/src/OpenSC-GUI/lib/opensc/lib/windows/libopensc.a -lz -lssl -lcrypto -llzma -Wl,-subsystem,windows E:/msys64/mingw64/lib/libQt5Guid.dll.a E:/msys64/mingw64/lib/libQt5Cored.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(mainwidget.cpp.obj): In function `MainWidget::pksc15PinChangeDone(Error)':
E:/msys64/usr/src/OpenSC-GUI/src/mainwidget.cpp:392: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(mainwidget.cpp.obj): In function `MainWidget::pksc15PinUnblockDone(Error)':
E:/msys64/usr/src/OpenSC-GUI/src/mainwidget.cpp:410: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::cancel()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:30: undefined reference to `sc_cancel'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::initScContext()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:73: undefined reference to `sc_context_create'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:75: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::connectCard(bool)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:92: undefined reference to `sc_detect_card_presence'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:96: undefined reference to `sc_wait_for_event'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:98: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:106: undefined reference to `sc_connect_card'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:109: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:114: undefined reference to `sc_lock'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:116: undefined reference to `sc_disconnect_card'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:118: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::connectReader(bool)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:131: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:138: undefined reference to `sc_wait_for_event'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:140: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:143: undefined reference to `sc_ctx_detect_readers'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:145: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:150: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:151: undefined reference to `sc_ctx_get_reader'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:152: undefined reference to `sc_detect_card_presence'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:162: undefined reference to `sc_ctx_get_reader'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:167: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::verifyCurrentSmartCard()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:184: undefined reference to `sc_detect_card_presence'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:195: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::verifyCurrentCardReader()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:207: undefined reference to `sc_ctx_detect_readers'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:207: undefined reference to `sc_ctx_get_reader_count'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:207: undefined reference to `sc_ctx_get_reader_by_name'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::cleanupScContext()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:224: undefined reference to `sc_release_context'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::cleanupSmartCard()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:233: undefined reference to `sc_unlock'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:234: undefined reference to `sc_disconnect_card'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::gatherPkcs15PinInfo()':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:246: undefined reference to `sc_pkcs15_bind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:248: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:257: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:259: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:260: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:262: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:275: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:280: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::changePinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:290: undefined reference to `sc_pkcs15_bind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:292: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:297: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:299: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:301: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:308: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:315: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:325: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:329: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj):E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:335: more undefined references to `sc_pkcs15_unbind' follow
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::changePinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:344: undefined reference to `sc_pkcs15_change_pin'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:348: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:353: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::unblockPinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:363: undefined reference to `sc_pkcs15_bind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:365: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:370: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:372: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:374: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:381: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:387: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:391: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:397: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj):E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:401: more undefined references to `sc_pkcs15_unbind' follow
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::unblockPinPkcs15(unsigned char const*, unsigned char const*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:406: undefined reference to `sc_pkcs15_unblock_pin'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:410: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:415: undefined reference to `sc_pkcs15_unbind'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::getPersonalDatafromCard(sc_pkcs15_card*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:428: undefined reference to `sc_pkcs15_get_objects'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:430: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:438: undefined reference to `sc_format_oid'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:439: undefined reference to `sc_compare_oid'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:454: undefined reference to `sc_pkcs15_read_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:456: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:471: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:487: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:493: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:500: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:511: undefined reference to `sc_pkcs15_free_data_object'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::getSerialDatafromCard(sc_pkcs15_card*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:530: undefined reference to `sc_format_path'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::getX509CertificateDatafromCard(sc_pkcs15_card*)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:562: undefined reference to `sc_format_path'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:566: undefined reference to `sc_select_file'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:568: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:576: undefined reference to `sc_pkcs15_read_certificate'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:578: undefined reference to `sc_strerror'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:582: undefined reference to `sc_pkcs15_free_certificate'
E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a(cardcontrolhandler.cpp.obj): In function `CardControlHandler::readDataFromFile(sc_pkcs15_card const*, sc_path const*, unsigned char*, unsigned long long)':
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:592: undefined reference to `sc_select_file'
E:/msys64/usr/src/OpenSC-GUI/src/cardcontrolhandler.cpp:596: undefined reference to `sc_read_binary'
collect2.exe: error: ld returned 1 exit status
Here is my CMakeLists.txt, which generates the command above:
# Bring header files into scope
set( LIB_DIR ${PROJECT_SOURCE_DIR}/lib )
include_directories(${LIB_DIR}/opensc/include)
include_directories (${LIB_DIR}/opensc/include/common)
include_directories(${LIB_DIR}/opensc/include/libopensc)
include_directories(${LIB_DIR}/opensc/include/scconf)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
SET(QT_USE_QTSVG TRUE)
find_package( ZLIB REQUIRED )
include_directories( ${ZLIB_INCLUDE_DIRS} )
find_package(OpenSSL REQUIRED)
include_directories( ${OPENSSL_INCLUDE_DIRS} )
#Adding forms
set( FORMS forms/mainwidget.ui forms/pukdialog.ui forms/aboutdialog.ui)
#Adding source files
set(SRCS main.cpp)
set(SRCS ${SRCS} mainwidget.cpp cardcontrolhandler.cpp error.cpp logger.cpp statusbar.cpp pukdialog.cpp aboutdialog.cpp x509certificatehandler.cpp )
#Adding headers
set(HEADERS mainwidget.h cardcontrolhandler.h statusbar.h logger.h pukdialog.h aboutdialog.h )
#Adding Resources
set(RESOURCES ../buergerkarte.qrc)
#Generation of Qt Stuff (moc files, ui headers and resource files)
QT5_WRAP_CPP( HEADERS_MOC ${HEADERS})
QT5_WRAP_UI( FORMS_HEADERS ${FORMS})
QT5_ADD_RESOURCES( RESOURCES_RCC ${RESOURCES})
#We have to include the binary directory because the qt stuff like ui headers will be generated there
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
#Creates executable from sources, moc headers (Qt), forms headers (Qt) and resources (Qt)
add_executable (${PROJECT_NAME} ${SRCS} ${HEADERS_MOC} ${FORMS_HEADERS} ${RESOURCES_RCC} ../buergerkarte.rc )
#Linking with special arguments for windows or linux platform
if( WIN32 )
set(LIBOPENSC ${LIB_DIR}/opensc/lib/windows/libopensc.a)
# target_link_libraries(${PROJECT_NAME} ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES} ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} -llcms -llzma -Wl,-subsystem,windows )
target_link_libraries(${PROJECT_NAME} ${QT_QTMAIN_LIBRARY} Qt5::Widgets ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} -llzma -Wl,-subsystem,windows )
elseif( APPLE )
set(LIBOPENSC ${LIB_DIR}/opensc/lib/mac_osx/libopensc.3.dylib)
#set(LIBOPENSC ./libopensc.3.dylib)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} )
else()
set(LIBOPENSC ${LIB_DIR}/opensc/lib/linux/libopensc.a)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${LIBOPENSC} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} )
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
ADD_CUSTOM_COMMAND (
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND lupdate -silent -I ../src ../src -ts ../translations/${PROJECT_NAME}_de.ts ../translations/${PROJECT_NAME}_it.ts
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
All the undefined references are contained inside the ${LIB_DIR}/opensc/lib/windows/libopensc.a file. The main program adds the header files from opensc. Why does the linker not see the functions inside the external library, despite it is added to the command?
g++.exe -std=c++11 -g2 -O0 -Wall -Wextra -pedantic -g -Wl,--whole-archive E:/msys64/usr/src/OpenSC-GUI/build/src/CMakeFiles/buergerkarte.dir/objects.a -Wl,--no-whole-archive -o buergerkarte.exe -Wl,--major-image-version,0,--minor-image-version,0 E:/msys64/mingw64/lib/libQt5Widgetsd.dll.a E:/msys64/usr/src/OpenSC-GUI/lib/opensc/lib/windows/libopensc.a -lz -lssl -lcrypto -llzma -Wl,-subsystem,windows E:/msys64/mingw64/lib/libQt5Guid.dll.a E:/msys64/mingw64/lib/libQt5Cored.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
I am using mingw-w64. Thanks!

Undefined reference using the mysql c++ connector

I'm trying to use the mySQL c++ connector.
I have downloaded and extracted the binaries following the mysql guide https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-installation-binary.html
When i include the xdevapi like so
#include <mysqlx/xdevapi.h>
I get the following errors
/tmp/cc6dzD4k.o: In function `mysqlx::string::operator std::__cxx11::basic_string, std::allocator >abi:cxx11 const':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/common.h:115: undefined reference to `mysqlx::string::Impl::to_utf8[abi:cxx11](mysqlx::string const&)'
/tmp/cc6dzD4k.o: In function `mysqlx::DbDoc::DbDoc()':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/document.h:153: undefined reference to `vtable for mysqlx::DbDoc'
/tmp/cc6dzD4k.o: In function mysqlx::DbDoc::~DbDoc()':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/document.h:127: undefined reference tovtable for mysqlx::DbDoc'
/tmp/cc6dzD4k.o: In function mysqlx::Value::print(std::ostream&) const':
/git_repos/FHM/Camera/Software/ExtractMetadata/Build/Linux/../../../mysql-connector-c++-8.0.13/include/mysqlx/devapi/document.h:507: undefined reference tomysqlx::common::Value::print(std::ostream&) const'
/tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x18): undefined reference to typeinfo for mysqlx::common::Value'
/tmp/cc6dzD4k.o:(.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x20): undefined reference tomysqlx::common::Value::print(std::ostream&) const'
/tmp/cc6dzD4k.o:(.rodata._ZTIN6mysqlx5ValueE[_ZTIN6mysqlx5ValueE]+0x28): undefined reference to `typeinfo for mysqlx::common::Value'
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'x86' failed
make: *** [x86] Error 1
My Makefile look like this:
g++ -I../../Src -I../../../Fee/Src \
-I/../../../OpenCV/include/opencv \
-I../../../OpenCV/include/opencv2 \
-I../../../mysql-connector-c++-8.0.13/include/ \
-L../../../OpenCV/lib/LinX86 \
-L../../../mysql-connector-c++-8.0.13/lib64/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread \
-g -D LINUX -o extractmetadata ../../Src/extractMetadata.cpp ../../../Fee/Src/Status.cpp \
-std=c++11 \
-lopencv_world -lstdc++fs \
Does anyone know what I'm missing here?
You are not linking with the MySQL library:
-L../../../mysql-connector-c++-8.0.13/lib64/libmysqlcppconn8-static.a
Use:
../../../mysql-connector-c++-8.0.13/lib64/libmysqlcppconn8-static.a
or:
-L../../../mysql-connector-c++-8.0.13/lib64/ -lmysqlcppconn8-static

Can't compile qt project with static lib curl

I am trying to compile a qt project with qtcurl using a statically built curl.
I am using the following to build a minimalist curl static library:
./configure --disable-shared --enable-static --prefix=/tmp/curl --disable-ldap --disable-sspi --without-librtmp --disable-ftp --disable-file --disable-dict --disable-telnet --disable-tftp --disable-rtsp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-smb --without-libidn --enable-ares
I am including
-L/tmp/curl/lib/libcurl.a
in the LIBS of the project, and
/tmp/curl/include
in the INCLUDEPATH
This is the output that I am getting:
QtCUrl.o: In function `QtCUrl::QtCUrl()':
QtCUrl.cpp:(.text+0x10d): undefined reference to `curl_easy_init'
QtCUrl.o: In function `QtCUrl::~QtCUrl()':
QtCUrl.cpp:(.text+0x32e): undefined reference to `curl_slist_free_all'
QtCUrl.cpp:(.text+0x355): undefined reference to `curl_easy_cleanup'
QtCUrl.o: In function `QtCUrl::setOptions(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0xcee): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xdac): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0xee9): undefined reference to `curl_slist_append'
QtCUrl.cpp:(.text+0xfe5): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1078): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x109f): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1155): undefined reference to `curl_easy_setopt'
QtCUrl.cpp:(.text+0x1290): undefined reference to `curl_easy_setopt'
QtCUrl.o: In function `QtCUrl::exec(QHash<CURLoption, QVariant>&)':
QtCUrl.cpp:(.text+0x1f27): undefined reference to `curl_easy_perform'
QtCUrl.o: In function `curlGlobalInit()':
QtCUrl.cpp:(.text+0xa6): undefined reference to `curl_global_init'
collect2: error: ld returned 1 exit status
What am I missing here?

Compiling libmodbus in Qt Creator on Windows throws undefined reference to '_imp_....' errors

I have the source .h and .c files for libmodbus (http://libmodbus.org/releases/libmodbus-3.0.6.tar.gz). I dumped them into my Qt Project after learning that Qt is smart enough to know the difference b/w c and c++ files.
I include modbus.h in main.cpp and I get about 50 errors (most of which are undefined reference errors). Note I did get libmodbus working in ubuntu using codeblocks and it was communicating fine. I'm trying this in windows now and both Qt and codeblocks seem to be angry at me.
Here is my .pro file.
QT += core
QT += widgets
QT -= gui
TARGET = testModBus
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
QMAKE_CXXFLAGS += -w
QMAKE_CFLAGS += -w
SOURCES += main.cpp \
modbus.c \
modbus-data.c \
modbus-rtu.c \
modbus-tcp.c
HEADERS += \
config.h \
modbus.h \
modbus-private.h \
modbus-rtu.h \
modbus-rtu-private.h \
modbus-tcp.h \
modbus-tcp-private.h \
modbus-version.h \
zModBus.h \
inttypes.h \
stdint.h
And here is my Qt Output when I try to Compile:
18:03:02: Starting: "E:\Qt\Tools\mingw48_32\bin\mingw32-make.exe"
E:\Qt\5.2.1\mingw48_32\bin\qmake.exe -spec win32-g++ -o Makefile ..\testModBus\testModBus.pro
E:/Qt/Tools/mingw48_32/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Users/SSK/Desktop/qtProjects/build-testModBus-Desktop_Qt_5_2_1_MinGW_32bit-Release'
g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release\testModBus.exe release/main.o release/modbus.o release/modbus-data.o release/modbus-rtu.o release/modbus-tcp.o -lglu32 -lopengl32 -lgdi32 -luser32 -LE:\Qt\5.2.1\mingw48_32\lib -lQt5Widgets -lQt5Gui -lQt5Core
release/modbus-tcp.o:modbus-tcp.c:(.text+0x24f): undefined reference to `_imp__select#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x2a3): undefined reference to `_imp__recv#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x2d7): undefined reference to `_imp__recv#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x30d): undefined reference to `_imp__shutdown#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x31c): undefined reference to `_imp__closesocket#4'
Makefile.Release:85: recipe for target 'release\testModBus.exe' failed
release/modbus-tcp.o:modbus-tcp.c:(.text+0x363): undefined reference to `_imp__setsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x394): undefined reference to `_imp__ioctlsocket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x3c6): undefined reference to `_imp__connect#12'
mingw32-make[1]: Leaving directory 'C:/Users/SSK/Desktop/qtProjects/build-testModBus-Desktop_Qt_5_2_1_MinGW_32bit-Release'
makefile:34: recipe for target 'release' failed
release/modbus-tcp.o:modbus-tcp.c:(.text+0x3e2): undefined reference to `_imp__WSAGetLastError#0'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x444): undefined reference to `_imp__select#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x47f): undefined reference to `_imp__getsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x517): undefined reference to `_imp__send#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x597): undefined reference to `_imp__WSAStartup#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x624): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x65e): undefined reference to `_imp__htons#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x66f): undefined reference to `_imp__inet_addr#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x6c8): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x74c): undefined reference to `_imp__getaddrinfo#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x780): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x7bb): undefined reference to `_imp__freeaddrinfo#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x7d5): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x82f): undefined reference to `gai_strerrorW'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x8bc): undefined reference to `_imp__select#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x96c): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x9ab): undefined reference to `_imp__setsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x9f0): undefined reference to `_imp__htons#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa0a): undefined reference to `_imp__inet_addr#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa2a): undefined reference to `_imp__bind#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa45): undefined reference to `_imp__listen#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa69): undefined reference to `_imp__htonl#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa85): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xb38): undefined reference to `_imp__getaddrinfo#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xb89): undefined reference to `_imp__setsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xb99): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xbc8): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xbf9): undefined reference to `_imp__freeaddrinfo#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc23): undefined reference to `_imp__bind#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc33): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc63): undefined reference to `_imp__listen#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc77): undefined reference to `_imp__freeaddrinfo#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xca5): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xcda): undefined reference to `gai_strerrorW'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xd61): undefined reference to `_imp__accept#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xd8b): undefined reference to `_imp__inet_ntoa#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xdc8): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xe19): undefined reference to `_imp__accept#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xe57): undefined reference to `_imp__closesocket#4'
e:/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: release/modbus-tcp.o: bad reloc address 0x250 in section `.rdata'
e:/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [release\testModBus.exe] Error 1
mingw32-make: *** [release] Error 2
18:03:04: The process "E:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" exited with code 2.
You need to include ws2_32.lib in your dependencies. I.e. in your *.pro file add the line:
LIBS += -lws2_32
Turns out that the error was generated because of __declspec(dllexport) in one of the header files. Removed that and it went away. Then it started throwing a new error which is where I'm currently stuck at.