[vtkusers] building static libraries using vtk libs

David Cole david.cole at kitware.com
Tue Nov 29 09:02:50 EST 2005


When you link in static libraries, you must specify all the libraries 
for all the classes, functions and data you use. If you are simply 
linking in your own static library that "references" VTK libraries, you 
must also link in the VTK libraries that are used.

CMake takes care of this automatically for you by tracking library 
dependencies. If you are using a CMake based build for both your exe and 
lib projects, there's probably a way to set it up so that all you have 
to do is TARGET_LINK_LIBRARIES to your lib and CMake will figure out the 
VTK part. If you're not using CMake for one of your projects, you have 
to link in all the VTK *.lib files that you need.

Another idea would be to link VTK statically into a DLL of yours (rather 
than a static lib of yours). That way, the DLL is fully linked to VTK 
and you will only have to link to the import library for the DLL from 
other projects. (But if you do this, the VTK stuff will *not* be 
exported from that DLL... On second thought, maybe this isn't a good 
idea if the "other projects" need access to VTK stuff -- which clearly 
they do, or you wouldn't have undefined link errors in the first place. :-))


HTH,
David

Jesse Corrington wrote:

> So what I am trying to do Is build my own static library on windows 
> that uses some of the vtk libraries.  The purpose is so i Can keep the 
> vtk stuff seperate from my current project and just link my one lib in 
> and use it.  So i converted my one project that was produsing an exe 
> to make a windows static library file, and that is working just fine.
>
> The problem is when i try to link my library that I built into another 
> project I get tons of link errors. Half of the link errors are for 
> undefined stuff in vtk. Do I have to link those into this project too, 
> shouldn't they already be in the library I built. I can get rid of 
> those errors by linking in the vtk libs i used to build my lib, but 
> then i Get a load of link erros that mainly said something is already 
> defined somewhere else. Some are stl, and other basic functions. Any 
> idea on how to fix this.
>
> Thanks a lot.
>
> Jesse Corrington
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today - it's 
> FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
> _______________________________________________
> 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