[vtkusers] building vtkMFC as a static library (Visual studio 2008)

John Drescher drescherjm at gmail.com
Tue Sep 1 09:33:46 EDT 2009


On Tue, Sep 1, 2009 at 5:52 AM, Mark Gooding<mark.gooding at gmail.com> wrote:
> Hello again,
>
> I've made some progress on this, I saw that the VTK_MFC_STATIC flag
> was linked to the compiler options in cmake, and that I needed to set
> the /MT flag in cmake to get it to build correctly. So what I do now
> (for the reference of anyone else having this problem...)
>
> In cmake:
>   select VTK_USE_GUISUPPORT
>   ensure BUILD_SHARED_LIBS is deslected
>   change all CMAKE_CXX_FLAGS_* to /MT from /MD
>   change all CMAKE_C_FLAGS_* to /MT from /MD
>   "Configure"
>   select VTK_USE_MFC
>   "Configure" & "Generate"
> In visual studio:
>   build without any changes
>
> Unfortunately, now that I have VTK building happily, I'm having a
> problem linking it into my project. Lots of LNK2019 errors.
>
> In the Project properties I've have:
> added the "VTK\include" directory to the "Additional Include
> Directories" of the "c/c++" tab.
> added the "VTK\libs" directory to the "Additional Library directories"
> of the "Linker" tab.
> added the vtk *.libs file to the "Additional Dependancies" under the
> "Linker" tab.
>
> am I missing any settings which are causing these link errors? any
> help here would be appeciated.
>

I would suggest using cmake to generate your project files for visual
studio for your main application. It is much easier handling all the
needed dependencies that way and it also adds functionality to the
project.

I do out of source builds for 2 different visual studio compilers with
the same code tree with separate build trees. This is very helpful
also for version control and backups since the source code tree has no
generated files in it at all. Its just code + a few CmakeLists.txt
files and other inputs for Cmake.

Also the built-in unit testing with CMake is very easy to use and the
automatic NSIS installer generation took less than 10 minutes to
setup.

If you do not want to go this way. Take a look at each unresolved
external and google a few to determine what library needs to be added.
This is not as hard as it seems.

John



More information about the vtkusers mailing list