Esri / cityengine-sdk

CityEngine is a 3D city modeling software for urban design, visual effects, and VR/AR production. With its C++ SDK you can create plugins and standalone apps capable to execute CityEngine CGA procedural modeling rules.
https://esri.github.io/cityengine/cityenginesdk
Apache License 2.0
203 stars 64 forks source link

built prt4cmd is not runnable on linux #72

Closed cookiedan42 closed 1 week ago

cookiedan42 commented 2 weeks ago

Description

trying to run prt4cmd built on WSL ubuntu raises error ./install/bin/prt4cmd: error while loading shared libraries: libglutess.so: cannot open shared object file: No such file or directory

Reproduction

  1. clone repo on wsl ubuntu
  2. follow building instructions for prt4cmd
  3. run the file which was just built

Hotfix

patch the downloaded libcom.esri.prt.core.so file to let it read libglutess.so in same directory
can be done in cmake when downloading dependencies
edited cmake which patches libcom.esri.prt.core.so using patchelf

Suggested solution

Rebuild the hosted release of libcom.esri.prt.core.so to include runpath $ORIGIN

mistafunk commented 2 weeks ago

Apologies for your troubles - which SDK version do you use?

cookiedan42 commented 2 weeks ago

This bug was initially encountered when using 3.1.9666/esri_ce_sdk-3.1.9666-rhel7-gcc93-x86_64-rel-opt which is the current default in cmake script for prt4cmd When I changed the cmake to download 3.2.9903/esri_ce_sdk-3.2.9903-rhel8-gcc112-x86_64-rel-opt, the same bug is observed

mistafunk commented 2 weeks ago

Thanks, I can reproduce the issue with the default WSL Ubuntu distro. Will investigate some more and let you know here.

mistafunk commented 2 weeks ago

The problem is caused by a difference in runtime linker behavior between Ubuntu and (our officially supported) RHEL-based distros (RHEL, Alma, Rocky, ...).

I'm probably oversimplifying, but Ubuntu by default interprets the RPATH value as RUNPATH. One difference between the two is that RUNPATH is only used for the current binary (prt4cmd in this case) while RPATH is inherited by all the dependencies. This means that the $ORIGIN value in prt4cmd is inherited also by libcom.esri.prt.core.so on RHEL-based systems and therefore libgluetess.so is found.

An alternative fix when compiling prt4cmd in WSL2 Ubuntu is to add this line to CMakeLists.txt:

target_link_options(${PROJECT_NAME} PRIVATE -Wl,--disable-new-dtags)

This will force the use of RPATH (RUNPATH is considered a "new" tag).

You can see the difference when looking at the RPATH/RUNPATH entries in the output of readelf -d install/bin/prt4cmd: on a RHEL-based distro it says (RPATH) Library rpath: [$ORIGIN] and on (WSL2) Ubuntu it says (RUNPATH) Library rpath: [$ORIGIN].

mistafunk commented 1 week ago

I've put corresponding actions in our backlog to fix the issue in one of the next releases.

Taking the liberty to close the issue. Feel free to reopen or create a new one in case of additional issues or questions.