BehaviorTree / BehaviorTree.CPP

Behavior Trees Library in C++. Batteries included.
https://www.behaviortree.dev
MIT License
3.03k stars 665 forks source link

Error compiling library with colcon build: undefined reference to `zmq_ctx_term' #857

Closed Shreeyak closed 2 months ago

Shreeyak commented 3 months ago

Describe the bug I'm trying to compile the library with colcon build so that I can use this with BehaviourTree.Ros2. It gives me an error related to libzmq. I have installed libzmq3-dev. My system also has libzmq5 installed (seems ros2 packages are depending on it) I've tried with both the master branch and the 3.8 branch.

Here's the error:

❯ cd BehaviorTree.CPP
❯ colcon build       
Starting >>> behaviortree_cpp
--- stderr: behaviortree_cpp                             
/usr/bin/ld: ../libbehaviortree_cpp.so: undefined reference to `zmq_ctx_term'
collect2: error: ld returned 1 exit status
gmake[2]: *** [tools/CMakeFiles/bt4_plugin_manifest.dir/build.make:101: tools/bt4_plugin_manifest] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:578: tools/CMakeFiles/bt4_plugin_manifest.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: ../libbehaviortree_cpp.so: undefined reference to `zmq_ctx_term'
collect2: error: ld returned 1 exit status
.
.
.
collect2: error: ld returned 1 exit status
gmake[2]: *** [examples/CMakeFiles/t06_subtree_port_remapping.dir/build.make:102: examples/t06_subtree_port_remapping] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:766: examples/CMakeFiles/t06_subtree_port_remapping.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< behaviortree_cpp [5.72s, exited with code 2]

Summary: 0 packages finished [6.22s]
  1 package failed: behaviortree_cpp
  1 package had stderr output: behaviortree_cpp

Note: I installed dependencies with conan and was able to build and install using cmake. But that gives linking errors with bt.ros2, so I'm trying to build bt.cpp using colcon.

How to Reproduce

Just clone the repo, cd into it and run colcon build.

Shreeyak commented 2 months ago

Found the issue. I tried re-installing libzmq3-dev, as well as all sorts of other libs. Turns out cmake was linking to a libzmq.so file in another program's directory (Nuke) rather than the system's installed program. After removing that directory from $PATH, cmake found the correct version of libzmq and I could compile the library with colcon.