I haven’t see the double entry pattern that you mention below.  However, you 
might want to tell CMake to embed a BUILD_RPATH in your libraries.  This should 
get around the issue of manually setting LD_LIBRARY_PATH.


From: CMake <> On Behalf Of Thiago Crepaldi
Sent: Thursday, February 14, 2019 12:43 AM
Subject: [CMake] Multiple occurrences of a library on linux (ldd)

Hello all,

After reading CMake Cookbook I have written my first "complex" CMake build 
script based on the superbuild pattern. I am excited to heave a better 
understanding on CMake, but I definitely will learn much more from experience 
and your kind help.
In summary, the standalone google test application `standalone_gtests` publicly 
links to `` and to pytorch libraries 
(``,``, ``).
`` also publicly links to pytorch libraries (I have a 
theoretical question on why `standalone_gtests` had to link to pytorch 
libraries if `` already did, but that can wait).

Compilation finishes successfully, but when I try to run `standalone_gtests`, 
it aborts because it cant find ``.
After executing `ldd standalone_gtests`, the weird result was that there were 
two entries for ``.
The first one maps to "not found" while the second had the correct path to the 
library. ``, which is also a pytorch library, has a single 
occurrence with full path.
If I add the (...)/pytorch_external/(...) (see ldd output below) path to 
LD_LIBRARY_PATH, then everything works, but I would like to avoid this, if 

`ldd ./subprojects/Build/datareaders_core_test/standalone_gtests => 
/home/dev/miniconda3/datareaders_py37/build/stage/datareader/lib/ => 
/home/dev/miniconda3/datareaders_py37/build/subprojects/Source/pytorch_external/torch/lib/ => not found => 

Have anyone seen multiple entries for the same library on ldd before? Why is 
that? Is it because `standalone_gtests` links to and to 
``, which in turn also links to ``?
Both CMakeLists.txt (libdatareader and standalone_gtests) succeeds at 
find_package(Torch REQUIRED QUIET) commands (${TORCH_LIBRARY} returns the 
correct path).

I run the same build on my Mac and everything works fine, so that is confined 
to linux environment. I have destroyed my conda environment and performed 
multiple clean builds in the process and no luck :(
Hoping this was some sort of ldconfig issue, I tried `sudo ldconfig` and `sudo 
rm /etc/`, but that doesn't fix it.

Any ideas?

best regards,

Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe:

Reply via email to