zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.93k stars 757 forks source link

mingw cross compilation fails #542

Open sunfishgit opened 2 years ago

sunfishgit commented 2 years ago

Hello, I am trying to compile a windows exe from linux using mingw however it results in an error. The issue seems to be related to the library not properly linking.

The build command: i686-w64-mingw32-g++ ../src/client.cpp -o client -cpp=14 -static-libgcc -static-libstdc++ -lzmq

Error: /usr/lib/gcc/i686-w64-mingw32/11.2.0/../../../../i686-w64-mingw32/bin/ld: /tmp/cc4yfeYE.o:client.cpp:(.text$_ZN3zmq7error_tC1Ev[__ZN3zmq7error_tC1Ev]+0x1e): undefined reference to `_imp__zmq_errno' /usr/lib/gcc/i686-w64-mingw32/11.2.0/../../../../i686-w64-mingw32/bin/ld: /tmp/cc4yfeYE.o:client.cpp:(.text$_ZNK3zmq7error_t4whatEv[__ZNK3zmq7error_t4whatEv]+0x13): undefined reference to `_imp__zmq_strerror' /usr/lib/gcc/i686-w64-mingw32/11.2.0/../../../../i686-w64-mingw32/bin/ld: /tmp/cc4yfeYE.o:client.cpp:(.text$_ZN3zmq9context_tC1Ev[__ZN3zmq9context_tC1Ev]+0xb): undefined reference to `_imp__zmq_ctx_new' /usr/lib/gcc/i686-w64-mingw32/11.2.0/../../../../i686-w64-mingw32/bin/ld: /tmp/cc4yfeYE.o:client.cpp:(.text$_ZN3zmq9context_t5closeEv[__ZN3zmq9context_t5closeEv]+0x1b): undefined reference to `_imp__zmq_ctx_term' collect2: error: ld returned 1 exit status

Any help is appreciated :)

caicaiking commented 1 year ago

seems not link zmq library correctly. sepecify the zmq.a or zmq.so path use -L option.

constsc commented 1 year ago

We also tried it. -> Able to compile and link with mingw1120_64 from Qt. But in libzmq there is a problem: The compiler is treated as GNU, but Microsoft socket libs are used. The caused strange run time errors. We were able to solve it faking MSVC and taking out COM/MIDL stuff.