0

I've been struggling for days to get image_proc for ROS2 going. It links to vision_opencv which in turn links to libboost_python3.

Now trying to run this I get the familiar:

dyld: Symbol not found: _PyBaseObject_Type
  Referenced from: /usr/local/opt/boost-python3/lib/libboost_python37.dylib
  Expected in: flat namespace
 in /usr/local/opt/boost-python3/lib/libboost_python37.dylib

Further investigation using the nm tool yields:

nm -u /usr/local/opt/boost-python3/lib/libboost_python37.dylib | grep _PyBaseObject_Type

_PyBaseObject_Type

That _PyBaseObject_Type is indeed undefined in libboost_python37.

Let's take a look at what libraries are linked to libboost_python37:

otool -L /usr/local/opt/boost-python3/lib/libboost_python37.dylib

usr/local/opt/boost-python3/lib/libboost_python37.dylib:
    /usr/local/opt/boost-python3/lib/libboost_python37.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

It is missing any dynamic link to Python which leads me to my first question:

  • Is python supposed to be linked to libboost_python37?

I've seen on other places online, an old question where someone posted their output from otool -L where it was included (although it is for the -mt file, my mt does not have it either.)

otool -L libboost_python-mt.dylib
libboost_python-mt.dylib:
    /opt/local/lib/libboost_python-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

(Their output)

My second question:

  • Does anyone know what the problem is or how to solve this?

Things gets a bit more complicated since I'm using the ROS2 build tool colcon and not just straight up compiling.

Some additional information: Some people suggests that this error solved by linking libboost_python37.dylib to libboost_python3.dylib because it can't be picked up. This is not the issue and it does not solve it.

I've also installed boost and boost-python3 from Brew, as well as compiled it myself, same both places. Python command is latest python 3.7.3 and it's "default" as in python --version gives 3.7.3.

Andreas Klintberg
  • 440
  • 1
  • 11
  • 29

1 Answers1

0

First question:

Is python supposed to be linked to libboost_python37?

Seems this is not necessary as seen here https://www.mail-archive.com/distutils-sig@python.org/msg23796.html and here https://github.com/Cantera/cantera/issues/319.

Some libraries are linked some are not.

Does anyone know what the problem is or how to solve this?

I found a workaround which I do not like at all, because I still don't know what the root cause is.

Adding your Python3 lib to the DYLD_INSERT_LIBRARIES env variable makes it work:

export DYLD_INSERT_LIBRARIES=/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python

Caveat: This made Virtualenv/pipenv stop working.

Which confirms that it's missing and Mojave can't pick it up when installed from Brew. Would love for someone else to confirm this is an issue with Brew/Mojave/Boost or image_proc ROS2 CMakeLists.txt.

Credit goes to this answer: https://stackoverflow.com/a/1990844/1829511

Andreas Klintberg
  • 440
  • 1
  • 11
  • 29