[vtkusers] Interacting with VTK under Mac OS X
Mike Jackson
imikejackson at gmail.com
Wed Mar 14 13:26:12 EDT 2007
Here is the deal. You have TWO choices. Pick ONE..
1) Build with RPATH=ON. This will encode the full path to the
libraries in each library. So basically, build VTK with RPATH=ON and
then DO NOT MOVE THE LIBRARIES from wherever cmake puts them. In
Xcode, you reference these libraries IN PLACE. This is what you want
to use when developing.
2) Build with RPATH=OFF but do a "make install". This will place the
libraries in /usr/local/lib by default and Encode in each library
where the library is located. This is what you want to use when
Deplorying your app to other people. You will need an installer than
places all the Vtk libs in /usr/local/lib for the user. While this
will work and some companies do it this way, this is really NOT the
mac way of doing things.
And a few comments from below: OS X does NOT put the path in the
libraries name, the linker does only with flags that are set by CMake.
What I would like to see are two more options for OS X:
1) Do not encode ANY path in the libraries. OS X by DEFAULT will
look in /usr/lib and /usr/local/lib (preferable) for libraries. This
would be a better situation.
2) Provide an option to set the "install_name" for the libraries,
or at least the prefix. I have my own hack in the OS X CMake module
that allows me to do this. Thus I can compile my VTK libs with a path
like the following: "@executable_path/../Libs" which allows me to
embed all the VTK libs in my .app package. This allows true "Drag and
Drop" installation of your application onto the OS X system. No
Installer needed.
You should NOT have to mess with DYLD_LIBRARY_PATH environment
variables if this is setup correctly.
Cheers
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Mar 14, 2007, at 12:26 PM, John Norris wrote:
> First of all, apparently just to keep things interesting, Mac OS X
> uses DYLD_LIBRARY_PATH, not LD_LIBRARY_PATH.
>
> You can also try using the -install_name flag when building VTK.
> Here's the relevant line from my CMakeCache.txt file.
>
> CMAKE_SHARED_LINKER_FLAGS:STRING=-fPIC -undefined dynamic_lookup -
> multiply_defined suppress -install_name libvtk${KIT}.dylib
>
> This builds the library without any built-in path (the default
> built-in path is wrong). You could also hard-code in the install
> directory, and then you won't need to worry about DYLD_LIBRARY_PATH.
>
> HTH,
> John
>
> Sean McBride wrote:
>> On 3/13/07 3:37 PM, Miguel Angel Rodriguez Florido said:
>>> Now, I have only a path problem because when I run the vtk command
>>> outside the /vtkBin/bin folder it gives me an error like it isn't
>>> able
>>> to load dylibs (even when I have declared the LD_LIBRARY_PATH
>>> pointing
>>> to the folder where the dylibs are). The same happens if I double-
>>> click
>>> vtk in the finder. I think that this is resolved if I create an
>>> ".app"
>>> for Mac.
>> This is no doubt due to the fact that Mac OS X (annoyingly) puts the
>> full path within dynamic libraries. One solution would be to
>> build with
>> static libraries instead. I believe there is another solution
>> though,
>> something to do with 'RPATH' but I don't know the details. If you
>> search the list archives, you will see it has been discussed before.
>
> --
> John Norris
> Research Programmer
> Center for Simulation of Advanced Rockets
> http://www.uiuc.edu/ph/www/jnorris
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-
> topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list