[zeromq-dev] Example for building against ZMQ with CMake + UDP Multicast Support
Stephan Opfer
opfer at vs.uni-kassel.de
Wed Jan 11 10:45:22 CET 2017
On 10.01.2017 23:04, Luca Boccassi wrote:
> Gaaaah. Why, gcc, why!!
>
> You need to pass the source file BEFORE the linker flags.
>
> This works:
>
> g++ Discovery.cpp `pkg-config --libs --cflags libzmq` -o test
>
> This fails:
>
> g++ `pkg-config --libs --cflags libzmq` Discovery.cpp -o test
>
> Unbelievable. And I'm sure I've tripped over this a few times already...
Thanks, that helped! Now I could compile it manually and know that I did install the zmq correctly.
With the help of this CMake Module: https://github.com/Kitware/Remus/blob/master/CMake/FindZeroMQ.cmake
I could make it work with my CMakeLists.txt.
These are the critical lines:
# Define where to find modules for ZeroMQ
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake CACHE INTERNAL "" FORCE)
add_definitions(-DZMQ_BUILD_DRAFT_API=1)
find_package(ZeroMQ)
The rest is just standard setting include dirs and linking libraries:
include_directories(include ${ZeroMQ_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${ZeroMQ_LIBRARIES})
--
Distributed Systems Research Group
Stephan Opfer T. +49 561 804-6283 F. +49 561 804-6277
Univ. Kassel, FB 16, Wilhelmshöher Allee 73, D-34121 Kassel
WWW: http://www.uni-kassel.de/go/vs_stephan-opfer/
More information about the zeromq-dev
mailing list