zeromq / cppzmq

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

[CMake] cppzmq-static not recognized as target #528

Open tbozo opened 2 years ago

tbozo commented 2 years ago

find_package(cppzmq) seems to work as: target_link_libraries(exe cppzmq) is working

but target_link_libraries(exe cppzmq-static) does not work as it tries to link with a lib cppzmq-static : /usr/bin/ld: cannot find -llibzmq-static collect2: error: ld returned 1 exit status

gummif commented 2 years ago

Did you build libzmq as a static library? Is there a libzmq.a or only a libzmq.so?

tbozo commented 2 years ago

the libs have been installed from a package not compiled. I do have the 2 files : /usr/lib/x86_64-linux-gnu/libzmq.so /usr/lib/x86_64-linux-gnu/libzmq.a

BTW I'm on Ubuntu 18.04

afiqahk commented 2 years ago

Any updates?

Same issue in Ubuntu 20.04 I have both shared and static libzmq as well: /usr/lib/aarch64-linux-gnu/libzmq.a /usr/lib/aarch64-linux-gnu/libzmq.so

cppzmq version 4.8.1, ZeroMQ installed through apt-get (libzmq3-dev version 4.3.2)

Elegye commented 1 year ago

Hello,

I encounter the same problem. I am using cppzmq, built manually. I used apt to get libzmq. I have both static and shared libs for cppzmq and libzmq.

Actually I cannot link statically cppzmq into my project, which is a big problem for deployments ...

find_package(cppzmq REQUIRED)

target_link_libraries(myTarget PUBLIC cppzmq cppzmq-static)

The error is : /usr/bin/ld: cannot find -llibzmq-static

I use Ubuntu 18.04 and CMake 3.10.

alfedotov commented 1 year ago

Same issue with cppzmq-static with MSVC with CMake 3.26.3

My CMakeLists.txt contains following:

include(ExternalProject)
ExternalProject_Add(
    ZeroMQ
    GIT_REPOSITORY https://github.com/zeromq/libzmq.git
    GIT_TAG v4.3.4
    CMAKE_ARGS -DCMAKE_MODULE_PATH:PATH=${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_TESTS=OFF -DBUILD_STATIC=ON
)
ExternalProject_Add(
    cppzmq
    DEPENDS ZeroMQ
    GIT_REPOSITORY https://github.com/zeromq/cppzmq.git
    GIT_TAG v4.10.0
    CMAKE_ARGS -DCMAKE_MODULE_PATH:PATH=${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DCPPZMQ_BUILD_TESTS=OFF
)

and then target_link_libraries(myTarget PUBLIC cppzmq-static)

Then I go to my MSVC project and don't see Additional Include Directories and only cppzmq-static.lib in the Additional Directories. Additional Library Directories has no path to the library.