Skip to content

Building pyrealsense2 does not include librealsense #9760

Description

@oliverdain

Camera Model: D415 (but also irrelevant)
FW Version: irrelevant
Operating System: Linux (Debian Bullseye) and OSX (Big Sur)
Platform: OSX and Debian Linux
Language: cmake

Issue Description

Intel doesn't provide a pre-build pyrealsense2 for OSX so I compiled my own. However, if I pip install the .whl file I built it is not statically linked against librealsense2 so users also have to install that. This is true on both OSX and Linux. However, I followed the instructions to compile everything and then ran python3.7 setup.py bdist_wheel to create the wheel file but somehow my version is different from the one built by Intel. For example, for the one I built if I run ldd on the pyrealsense2.cpython-37m-x86_64-linux-gnu.so that is included in the wheel I get:

        linux-vdso.so.1 (0x00007fffb6dec000)
        librealsense2.so.2.49 => not found
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9767761000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f976761d000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9767603000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f976743e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f9767d68000)

but if I download the official Linux one and run ldd I get:

        linux-vdso.so.1 (0x00007ffebd9f1000)
        libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007fb2f3ca0000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb2f3ad3000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb2f398f000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb2f3975000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb2f3953000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb2f378e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fb2f53bc000)
        libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fb2f3764000)

so the official one does not need to be dynamically linked against librealsense2.so.2.49. I suspect the instructions just need to be updated.

To be clear, here's the steps I followed:

  1. Run cmake with -DBUILD_PYTHON_BINDINGS:bool=true and '-DPython_ADDITIONAL_VERSIONS=3.7'.
  2. Run make -j4 pyrealsense2 pybackend2
  3. Copy pybackend2.cpython-37m-x86_64-linux-gnu.so and pyrealsense2.cpython-37m-x86_64-linux-gnu.so into wrappers/python/pyrealsense2
  4. Run the find_librs_version.py script
  5. Run python3.7 setup.py bdist_wheel

I imagine I need some extra cmake flag to have my pyrealsense2.cpython-37m-x86_64-linux-gnu.so statically linked against librealsense2 but I don't see an obvious flag and it's not documented.

Note that the main reason I'm doing this is that there isn't an OSX version so I need to compile that. I only repeated the steps on Linux so I could compare to the official pyrealsense2 wheel provided by Intel.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions