[vtkusers] OSX Mountain Lion - shared libraries

Boxer, Aaron Aaron.Boxer at uhn.ca
Fri Jan 24 10:48:46 EST 2014


>>When you build VTK, or when you build your own programs against the 
>>VTK libraries, cmake bakes the load path into the libraries and the 
>>executables that it produces.  So in general, no paths have to be set.
>> The run-time libraries will be found automatically.
>>
>>CMake will strip out these baked-in library paths when you run a make 
>>install, so that the installed VTK programs will only search the 
>>system library paths, rather than searching your build directory for 
>>the libraries.  So if you install libraries to some location that is 
>>not in the system library path, then you will need to use 
>>DYLD_LIBRARY_PATH or some other path-setting mechanism.
>>
>>More information (general info, not specific to OS X) is available on 
>>the wiki: http://www.cmake.org/Wiki/CMake_RPATH_handling
>
> And it is the complication of shared libraries having these built-in paths that makes static libraries preferable in many situations.
>
> Of course, as with everything, "it depends" what you're doing.  Aaron, what are you doing with VTK exactly?  If you are trying to build a stand-alone .app then using static libraries will be preferable because the linker will just add them to your main executable, and you won't have to worry about embedding the dylibs in your .app, plus the linker will be able to dead strip a lot of VTK away for you.
>
That isn't really specific to OS X (the same arguments hold true on Windows and Linux), and this really comes down to what you are doing and how you wish to deploy your application. For normal development shared libraries are often preferable, with the embedded paths, as relinking will be faster for example (and use less RAM). The CMake fixup bundle code can help a lot deploying shared libs, even with plugins, for example.

I have developed on Linux, OS X, and Windows and prefer to use shared libraries during development, but might use static for deployment. We work to ensure both work as smoothly as possible across all of the platforms (Windows for example lacks a concept of RPATHs, so things are different there).

Thanks for the insight, Marcus.    



This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient. 
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. 
If you have received this e-mail in error, please contact the sender and delete all copies. 
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.



More information about the vtkusers mailing list