[vtkusers] static libs...

Obada Mahdi omahdi at gmx.de
Wed Oct 18 16:11:59 EDT 2006


Hi Frederic!

On 10/18/06, fred <fredmfp at gmail.com> wrote:
> Obada Mahdi a écrit :
>
> > Unlike shared libraries, static libraries do not carry dependency
> > information, so every required library needs to be stated explicitly
> > (in order, which means that a library is to be given on the command
> > line after the one that depends on it).  You can obtain dependency
> > information from
> > "<PREFIX>/lib/vtk-<VERSION>/VTKLibraryDepends.cmake",
>
[excerpt from VTKLibraryDepends.cmake]
>
> So I tried:
> gcc -Wall vtktest.c -o vtktest -static -lvtksys -lvtkDICOMParser
> -lvtkMPEG2Encode -lpthread -ldl -lm -lvtkCommon -lvtkFiltering -lvtkpng
> -lvtkzlib -lvtkjpeg -lvtktiff -lvtkexpat -lvtkIO
>
> but I get a lot of error messages too.
>
> What's wrong ?

You need to reverse the order in which libraries are given--I guess my
description was a bit confusing, sorry.  Could you please try again
with

g++ -Wall vtktest.c -o vtktest -static -lvtkIO -lvtkFiltering
-lvtkCommon -lvtkDICOMParser -lvtkpng -lvtkzlib -lvtkjpeg -lvtktiff
-lvtkexpat -lvtkMPEG2Encode -lvtksys -lpthread -ldl -lm

I still think that you should use "g++".  It might be enough to add
-lstdc++, but I am not if that is the only difference.  Note also that
although some of those libraries from the vtkIO dependency chain might
not be required for linking after all, you should not bother with
that, as they will not enlarge the resulting executable.

If that still does not help, try using CMake for configuring the
project and generate a Makefile. Then a "make VERBOSE=1" will give you
a chance to see what commands CMake figured out for building your
project.  Here is a sample CMakeLists.txt that might just do the
trick:

----BEGIN----
PROJECT (vtktest)

FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

ADD_EXECUTABLE(vtktest vtktest.c)
TARGET_LINK_LIBRARIES(vtktest vtkIO)
----END----


Regards,

Obada



More information about the vtkusers mailing list