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

Mark Gooding mark.gooding at gmail.com
Tue Sep 1 05:52:29 EDT 2009


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.

Many thanks,

Mark




2009/8/27 Mark Gooding <mark.gooding at gmail.com>:
> Hi there,
>
> i've been trying to build vtkMFC as a static library and am not be
> overly successful. I came across a thread about this on the vtk
> mailing list (http://www.vtk.org/pipermail/vtkusers/2009-February/099337.html).
> However I don't seem to be able to get it to work. Could anyone give
> me some pointers.
>
> Here's what I'm doing:
>
> In cmake:
>   select VTK_USE_MFC
>   ensure BUILD_SHARED_LIBS is deslected
> In Visual Studio:
>   change properties for vtkMFC project
>       change "Configuration Type" to "Static Library"
>       change "Use of MFC" to "Use MFC in a static library"
>
> when building vtkMFCWindow fails with "
> fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds"
>
> but the MD switch is for creating dlls. What am I missing?
>
> Cheers,
>
> Mark
>



More information about the vtkusers mailing list