cppzmq icon indicating copy to clipboard operation
cppzmq copied to clipboard

[CMake] cppzmq-static not recognized as target

Open tbozo opened this issue 4 years ago • 5 comments

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

tbozo avatar Nov 12 '21 09:11 tbozo

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

gummif avatar Nov 12 '21 11:11 gummif

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

tbozo avatar Nov 12 '21 14:11 tbozo

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)

afiqahk avatar Jan 13 '22 04:01 afiqahk

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.

Elegye avatar Jul 04 '23 12:07 Elegye

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.

alfedotov avatar Jul 04 '23 13:07 alfedotov