[CMake] Executing python though CMake and linking libraries

Kit Chambers kit.chambers.kc at gmail.com
Fri Nov 25 13:21:21 EST 2016


Hmmm… I get the same error if I use absolute paths.

I don’t really understand why the shell environment used to launch CMake and make is not being inherited by the executed commands. 

Kit

> On 25 Nov 2016, at 13:23, tonka3100 at gmail.com wrote:
> 
> Hey,
> 
> I think your actual working directory is wrong. I would recommend to use absolute paths for the python interperter (there is a find_package module for the interpreter) and maybe also for your script. The custom command support a workingdirectory variable as far as i know.
> 
> Hope that help you.
> 
> Greetings
> Tonka
> 
>> Am 25.11.2016 um 10:04 schrieb Kit Chambers <kit.chambers.kc at gmail.com>:
>> 
>> 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
>> -- 
>> 
>> Powered by www.kitware.com
>> 
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>> 
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>> 
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake



More information about the CMake mailing list