[vtkusers] OSX Mountain Lion - shared libraries

Marcus D. Hanwell marcus.hanwell at kitware.com
Fri Jan 24 10:37:29 EST 2014


On Fri, Jan 24, 2014 at 10:30 AM, Sean McBride <sean at rogue-research.com> wrote:
> On Thu, 23 Jan 2014 20:59:15 -0700, David Gobbi said:
>
>>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).

Marcus


More information about the vtkusers mailing list