[vtkusers] vtkMFC as .dll vs static library

Kevin Osborn planck at netspeed.com.au
Thu Feb 5 17:17:05 EST 2009


I don't have an answer to the basic problem that you have but when 
building a VTK project to debug with Visual Studio 2008 I routinely see 
warnings about conflicts between msvcrt and other libraries. These are 
warnings, not errors. When I build a release build, no warnings are present.


Alon Mozes wrote:
> Hi All,
> This had followed a thread ("Compile with Visual Studio 2008") but I 
> think has become different enough...
>  
> I have an MFC project that I'm trying to upgrade in Visual Studio 
> (from .NET 2003 to 2008) that uses vtk (used to be 5.0.3, now 
> upgrading to 5.2.1).  The default use of MFC in the project is as a 
> .dll but I'm having trouble with that.  In addition, I'd prefer to 
> have it as a static library so the entire .exe is self-contained (no 
> need to install additional dependencies).  Either path, I've run into 
> difficulty.
>  
> Path 1: as a .dll
> I build vtk 5.2.1 using CMake and everything is ok.  I find the 
> vtkMFC.dll as expected in the build/debug/bin dir.  In visual studio, 
> I can compile and link successfully, but when I run, it can't find the 
> .dll.  I've added a dir in the Tools->Options->Projects and 
> Solutions->VC++ Dirs as I've seen on some help pages, but it didn't 
> seem to have any effect.  I've copied the .dll directly into my 
> project's debug folder so it's guaranteed to find it, and it does, but 
> the app crashes (and I'm sure this is not the proper way to have it 
> find the .dll - I'd just like to see the app working).  This seems to 
> be unique to the change of vtkMFC as a .dll as I've had the project 
> running with other include/library files just fine.  Any suggestions?
>  
> Path 2: as a statically linked library (This is more desirable)
> I change CMake settings so it should build vtk as a statically linked 
> library, rather than .dll.  By that I mean, I change all "MD" and 
> "MDd" references to "MT" and "MTd".  The "Use of MFC" setting offers 3 
> options: "Standard Windows Library", "Use MFC as shared .dll", and 
> "Use MFC as static library".  I verify that in the vtkMFC project the 
> "Use of MFC" setting is "Use MFC as static library" as well as in my 
> project.  vtkMFC seems to successfully build as a .lib.  (Interseting 
> note: in 5.0.3, the "Use of MFC" setting is "6" and I haven't been 
> able to find anywhere what that means).  In my project, I remove any 
> setting of _AFXDLL (and verify it's not set in the vtkMFC project).  
> The project compiles but has errors when linking.  Seems to be a 
> conflict between libcmt.lib and msvcrt.lib.  It suggests setting 
> /nodefaultlib - which I've tried - but that results in other linker 
> errors saying it can't find the most basic functions.  I'm guessing I 
> can't just sweepingly use the /nodefaultlib switch.  Does anyone know 
> which .libs I have to ignore to get vtkMFC to work as a static library 
> in my project?  Has anyone used vtkMFC as a static library?
>  
> Thanks for all the help.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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