zeromq / cppzmq

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

cmake unable to find zmq library #276

Open vrnmthr opened 5 years ago

vrnmthr commented 5 years ago

I'm trying to use zeromq with c++ and python bindings.

Here's my current installation script:

# adds the latest stable package available
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/network:/messaging:/zeromq:/release-stable/xUbuntu_16.04/ /' > /etc/apt/sources.list.d/network:messaging:zeromq:release-stable.list"
sudo apt-get update
sudo apt-get install -y libzmq3-dev

wget -nv https://download.opensuse.org/repositories/network:messaging:zeromq:release-stable/xUbuntu_16.04/Release.key -O Release.key
sudo apt-key add - < Release.key
sudo apt-get update

# installs python bindings
sudo -H pip3 install pyzmq

# install c++ bindings
cd ~
git clone https://github.com/zeromq/cppzmq
cd cppzmq
git submodule update --init
git checkout v4.3.0
mkdir build
cd build
cmake ..
sudo make -j4 install

At the last sudo make -j4 install, it crashes with the following error:

CMakeFiles/unit_tests.dir/message.cpp.o: In function `zmq::message_t::routing_id() const':
message.cpp:(.text._ZNK3zmq9message_t10routing_idEv[_ZNK3zmq9message_t10routing_idEv]+0x10): undefined reference to `zmq_msg_routing_id'
CMakeFiles/unit_tests.dir/message.cpp.o: In function `zmq::message_t::set_routing_id(unsigned int)':
message.cpp:(.text._ZN3zmq9message_t14set_routing_idEj[_ZN3zmq9message_t14set_routing_idEj]+0x1c): undefined reference to `zmq_msg_set_routing_id'
CMakeFiles/unit_tests.dir/message.cpp.o: In function `zmq::message_t::group() const':
message.cpp:(.text._ZNK3zmq9message_t5groupEv[_ZNK3zmq9message_t5groupEv]+0x10): undefined reference to `zmq_msg_group'
CMakeFiles/unit_tests.dir/message.cpp.o: In function `zmq::message_t::set_group(char const*)':
message.cpp:(.text._ZN3zmq9message_t9set_groupEPKc[_ZN3zmq9message_t9set_groupEPKc]+0x1c): undefined reference to `zmq_msg_set_group'
collect2: error: ld returned 1 exit status
tests/CMakeFiles/unit_tests.dir/build.make:253: recipe for target 'bin/unit_tests' failed
make[2]: *** [bin/unit_tests] Error 1
CMakeFiles/Makefile2:88: recipe for target 'tests/CMakeFiles/unit_tests.dir/all' failed
make[1]: *** [tests/CMakeFiles/unit_tests.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

Am I missing some piece somewhere? In the instructions it said to build even the first zeromq from scratch, but I just followed the instructions to install from a package on my system.

bluca commented 5 years ago

You are all set. The libzmq3-dev package already includes zmq.hpp. You don't need to build this repository.

Note that, if what you pasted is what you did, you added the key after installing libzmq3-dev which probably means you don't have the version from our repos.

vrnmthr commented 5 years ago

Ok - I don't have to clone and compile cppzmq at all?

bluca commented 5 years ago

no

kurdybacha commented 5 years ago

just an explanation for someone with similar issue: this is because enabled "build with draft" for git cloned cppzmq whereas libzmq (installed in the system) was not build with draft. One of the reason to drop "build with draft" for cloned repo unless explicitly specified @bluca