eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.61k stars 2.33k forks source link

Static linking broken on windows #3035

Open silabs-beta opened 2 months ago

silabs-beta commented 2 months ago

Description

I try to use the libmosquitto package in my project with static linking. I use -static linker flag and I get the linker flags for the package like this: pkg-config --libs --static libmosquitto. The output of the pkg-config is -lmosquitto. The issue has been analysed and patched in https://github.com/msys2/MINGW-packages/issues/20604

Expected behaviour

The flags provided by pkg-config should work as is.

Actual behaviour

The linker fails like this: cannot find -lmosquitto: No such file or directory

Environment / Steps to reproduce the issue

I used the prebuilt binaries v2.0.18 from the mingw repo. I used basic-1.c and the following build command for testing.

gcc -static basic-1.c $(pkgconf -libs -cflags -static libmosquitto)

I have also tried to build libmosquitto from the master branch (15292b2) but I experienced the same issue. I used the following build command (as seen here):

mkdir build && cd buld
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DWITH_STATIC_LIBRARIES=ON -DWITH_PIC=ON ..
cmake --build .

I'm using CMake version 3.28.1. I tried to build on the develop branch too, but it failed so I gave up trying. Therefore I don't know if any of the issues on the master branch are actually fixed on the develop branch.