[ITK-dev] Not linking against libpython

Bradly Lowekamp blowekamp at mail.nih.gov
Fri Apr 8 13:42:02 EDT 2016


Hello,

Thanks for your help with this issue.

Here is the resulting CMake “module” created:

https://github.com/SimpleITK/SimpleITK/blob/master/CMake/sitkTargetLinkLibrariesWithDynamicLookup.cmake <https://github.com/SimpleITK/SimpleITK/blob/master/CMake/sitkTargetLinkLibrariesWithDynamicLookup.cmake>

It implements a function called sitk_target_link_libraries_with_dynamic_lookup. SimpleITK uses it for linking for all loadable modules to the wrapped languages libraries.

In CMake, Matt pointed to me that there is some undocumented functionality with not linking to LibPython in a undocumented PYTHON_ADD_MODULE method[1].


Please consider adding a bonified intrinsic CMake way of doing “weak” or “with dynamic lookup” linking, perhaps as a option to the target_link_libraries function.

Thanks!
Brad

[1] https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake#L293

> On Mar 24, 2016, at 10:16 AM, Bradly Lowekamp <blowekamp at mail.nih.gov> wrote:
> 
> 
>> On Mar 23, 2016, at 4:27 PM, Brad King <brad.king at kitware.com> wrote:
>> 
>> On 03/23/2016 04:16 PM, Bradley Lowekamp wrote:
>>> 1) Is there a more CMAKE-ic way for doing this?
>>>  With all they library and linking properties?
>> 
>> I'm not certain what you're asking because if you don't want to link
>> to a library then don't pass it to target_link_libraries and then
>> propagation doesn't matter.  What role do you think CMake might play
>> in doing this?
> 
> I thought that there may have been something I was missing with options to target_link_librares options or the MODULE options in add_libraries.
> 
> What role could it?
> 1) There could be a target property corresponding to if undefined symbols are allowed. It would be true for this case of linux, where it defaults to allowing undefined symbols. Conversely OSX does not allow undefined symbols by default but has a flag to enable them.
> 2) There could be an additional target_link_library keyword to specify the type of linking, say “WEAK”. This could cause a SHARED or MODULE target to to be linked against this library if undefined symbols are NOT allowed.
> 3) This is the first case I have seen where a MODULE library target, as in one intended to be dynamically loaded, should be handled differently.
> 
> 
> 
>> 
>>> 2) Is there a way to know if the linker allows undefined symbols
>>>  for shared libraries?
>> 
>> CMake does not provide this information directly.  You could use a
>> try_compile to test it.
> 
> Do you know of a try_compile example which creates a shared library? 
> 
> Just need to compile and link this as a shared library:  ”extern int bar(void); int foo(void) {return bar()+1;}”
> 
> Lastly I am working on a couple experiments here: https://github.com/blowekamp/CMakeSecondaryDependencies
> 
> Thanks!
> Brad
> 
>> 
>> -Brad K
>> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20160408/b5a73795/attachment.html>


More information about the Insight-developers mailing list