The link errors you are seeing may be because there is an old .obj file still around that references the prior setting. Please do a clean build of *everything* in your whole project with all &quot;MT&quot; flags and static libs. The fact that you are getting a link error referring to msvcrt.lib means there is still something around that was compiled with /MD.<div>
<br></div><div>You can use the dumpbin tool from a Visual Studio command prompt:<span class="Apple-style-span" style="font-family: -webkit-monospace; font-size: 12px; line-height: 13px; white-space: pre; "></span></div><div>
<span class="Apple-style-span" style="font-family: -webkit-monospace; font-size: 12px; line-height: 13px; white-space: pre; ">dumpbin /directives *.lib</span></div><div>to find which .lib files you have built that contain references to msvcrt.lib -- those are the ones that need to be rebuilt with /MT flags to prevent the errors you&#39;re seeing.</div>
<div><br></div><div><br></div><div>HTH,</div><div>David</div><div><br><div><div><br><div class="gmail_quote">On Thu, Feb 5, 2009 at 11:42 AM, Alon Mozes <span dir="ltr">&lt;<a href="mailto:amozes77@yahoo.com">amozes77@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit"><div>Hi All,</div>
<div>This had followed a thread (&quot;Compile with Visual Studio 2008&quot;) but I think has become different enough...</div>
<div>&nbsp;</div>
<div>I have an MFC&nbsp;project that I&#39;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).&nbsp; The default use of MFC in the project is as a .dll but I&#39;m having trouble with that.&nbsp; In addition, I&#39;d prefer to have it as a static library so the entire .exe is self-contained (no need to install additional dependencies).&nbsp; Either path, I&#39;ve run into difficulty.</div>

<div>&nbsp;</div>
<div>Path 1: as a .dll</div>
<div>I build vtk 5.2.1 using CMake and everything is ok.&nbsp; I find the vtkMFC.dll as expected in the build/debug/bin dir.&nbsp; In visual studio, I can compile and link successfully, but when I run, it can&#39;t find the .dll.&nbsp; I&#39;ve added a dir in the Tools-&gt;Options-&gt;Projects and Solutions-&gt;VC++ Dirs as I&#39;ve seen on some help pages, but it didn&#39;t seem to have any effect.&nbsp; I&#39;ve copied the .dll directly into my project&#39;s debug folder so it&#39;s guaranteed to find it, and it does, but the app crashes (and I&#39;m sure this is not the proper way to have it find the .dll - I&#39;d just like to see the app working).&nbsp; This seems to be unique to the change of vtkMFC as a .dll as I&#39;ve had the project running with other include/library files just fine.&nbsp; Any suggestions?</div>

<div>&nbsp;</div>
<div>Path 2: as a statically linked library (This is more desirable)</div>
<div>I change CMake settings so it should build vtk as a statically linked library, rather than .dll.&nbsp; By that I mean, I change all &quot;MD&quot; and &quot;MDd&quot; references to &quot;MT&quot; and &quot;MTd&quot;.&nbsp; The &quot;Use of MFC&quot; setting offers 3 options: &quot;Standard Windows Library&quot;, &quot;Use MFC as shared .dll&quot;, and &quot;Use MFC as static library&quot;.&nbsp; I verify that in the vtkMFC project the &quot;Use of MFC&quot; setting is &quot;Use MFC as static library&quot; as well as in my project.&nbsp; vtkMFC seems to successfully build as a .lib.&nbsp; (Interseting note: in 5.0.3, the &quot;Use of MFC&quot; setting is &quot;6&quot; and I haven&#39;t been able to find anywhere what that means).&nbsp; In my project, I remove any setting of _AFXDLL (and verify it&#39;s not set in the vtkMFC project).&nbsp; The project compiles but has errors when linking.&nbsp; Seems to be a conflict between libcmt.lib and msvcrt.lib.&nbsp; It suggests setting /nodefaultlib - which I&#39;ve tried - but that results in other linker errors saying it can&#39;t find the
 most basic functions.&nbsp; I&#39;m guessing I can&#39;t just sweepingly use the /nodefaultlib switch.&nbsp; Does anyone know which .libs I have to ignore to get vtkMFC to work as a static library in my project?&nbsp; Has anyone used vtkMFC as a static library?</div>

<div>&nbsp;</div>
<div>Thanks for all the help.</div></td></tr></tbody></table><br>

      </blockquote></div><br></div></div></div>