[CMake] Executing python though CMake and linking libraries

Kit Chambers kit.chambers.kc at gmail.com
Fri Nov 25 04:04:53 EST 2016


I have a Cmake custom target which runs a python script:

add_custom_target(run
                 COMMAND python myscript.py
                  ) 

And the script myscript.py imports a Compiled library 

import myproj.mylilb

where mylib is actually a C++ library generated with python bindings (using vtkPython). This intern links against some other C++ libraries I use etc.


When I run the script normally from the command line everything works fine, but if I try to run the target I get linker errors.

$ make run

Traceback (most recent call last):
 File "myscript.py", line 8, in <module>
   import myproj.mylilb
ImportError: dlopen(/Users/kitchambers/Applications/ogFramework/lib/python2.7/site-packages/myproj/mylib.so, 2): Library not loaded: libSpProcSupport.so
 Referenced from: /Users/kitchambers/Applications/ogFramework/lib/python2.7/site-packages/myproj/mylib.so
 Reason: image not found

To me it looks like my LD_LIBRARY_PATH and DYLD_LIBRARY_PATH are not being passed through CMake to Python so it cannot find all the necessary sub libraries. However, i cannot work out how to pass this information through.

Any help would be greatly appreciated.

Cheers

Kit


More information about the CMake mailing list