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

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

我的项目链接了uwebsockets。 链接库:

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;
}

我遇到错误

libuv.c:-1: error: undefined reference to `uv_is_closing'
libuv.c:-1: error: undefined reference to `uv_poll_init_socket'
……

35 个函数未定义,但我无法在 main.cpp 中直接调用这些函数。

os: Windows10 x64

IDE: QtCreator4.14.2

编译器:MinGW 32 位

充满错误日志

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.

有没有linking顺序问题?我看到 usockets link 落后于 libuv,也许我们可以尝试交换顺序:先到 link usockets

您正在使用静态 linkage,并且 usockets 取决于 libuv,因此交换序列将解决问题。

相关问题:

Why does the order in which libraries are linked sometimes cause errors in GCC?