开发者

How do I build a statically linked program in Visual Studio 2010?

I need to make a static release of my program to turn in to my professor, but whenever I compile the program and开发者_C百科 then run it on another computer it tells me it couldn't find a dll so obviously I'm doing something wrong. What do I need to do to make a static build?


After you change the project settings to a static build, choose Build All (or Rebuild All). If that doesn't work, choose "Delete all intermediate files" and build.


Problems loading .dll dependencies usually stem from one of two issues:

  • Assemblies are missing in the GAC.
  • Assemblies are missing in the application directory.

In this case, my bet is that you can resolve the problems by ensuring the following:

  • Provide to your professor all assemblies that are copied to your output folder as a package.
  • Ensure your professor has the proper dependencies installed. For example, if your application is .NET, ensure that your professor has installed the correct .NET framework (probably .NET 4, if this is the case).


If you are compiling a C/C++ program look at a vcredist exe executable in your compiler's installation directory. This redistributable contains side-by-side assemblies needed to run your application. It is specific to the version of the compiler you are using. When you make a setup or deploy you have to install this on the target computer. Also do not forget to compile a "release". A "debug" won't run on other machines without having the debug dlls installed there, which are not part of the vcredist.

Here is a link to the vcredist on microsoft's site. You have to take the one exactly matching the compiler you are using. Better is to take the one from the installation dir of the compiler to be sure it matches.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜