cms-patatrack / pixeltrack-standalone

Standalone Patatrack pixel tracking
Apache License 2.0
17 stars 35 forks source link

Add `-rpath` to the shared libraries #408

Closed fwyzard closed 10 months ago

fwyzard commented 10 months ago

On Ubuntu 22.04 using the system compiler (gcc 11.4.0) the calls to dlopen() fail because the plugins are not able to find the shared libraries.

For example

$ ./cudatest
Found 1 devices
terminate called after throwing an instance of 'std::runtime_error'
  what():  unable to load /home/fwyzard/src/pixeltrack-standalone/lib/cudatest/pluginTest1.so because libCUDACore.so: cannot open shared object file: No such file or directory
Aborted (core dumped)

And according to ldd:

$ ldd lib/cudatest/pluginTest1.so
        linux-vdso.so.1 (0x00007ffc3977e000)
        libFramework.so => not found
        libCUDACore.so => not found
        libDataFormats.so => not found
        libtbb.so.12 => /home/fwyzard/src/pixeltrack-standalone/external/tbb/lib/libtbb.so.12 (0x00007fd0bb44f000)
        libcudart.so.12 => /usr/local/cuda/lib64/libcudart.so.12 (0x00007fd0bb000000)
        libbacktrace.so.0 => /home/fwyzard/src/pixeltrack-standalone/external/libbacktrace/lib/libbacktrace.so.0 (0x00007fd0bb43b000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd0bac00000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd0bb41b000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd0ba800000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd0bb4f9000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd0bb414000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd0bb40f000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd0bb40a000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd0bb323000)

Passing the -rpath option when building the plugins fixes the issue:

$ ./cudatest 
Found 1 devices
Processing 1000 events, with 1 concurrent events and 1 threads.
TestProducer  Event 1 stream 0 ES int 42 FED 1200 size 2152
TestProducer2::acquire Event 1 stream 0 array 0x7f317f200000
TestProducer3 Event 1 stream 0
TestProducer2::produce Event 1 stream 0
...
Processed 1000 events in 1.066554e+01 seconds, throughput 93.7599 events/s, CPU usage per thread: 14.8%

For simplicity and consistency, it is now passed when building all shared libraries.