0

When I make a simple program Whether Console or win32 When I copy the program to other pc or other os give me an error message, must have specific dll or lib files to the program works .

Example: I created a simple console program and when it runs on other Windows or other pc asked me files (msvcp100d.dll, msvcr100d.dll) needed to the program works .

My question: How can I run the program on any pc or Windows without it asks any file link, or even file libraries, or other.

Note: I'm using visual studio 2010 express edition with windows 7.

Lion King
  • 32,851
  • 25
  • 81
  • 143
  • 1
    You need to install the Visual C++ Runtime 10.0. You can download it for free from Microsoft's web site. (32-bit: https://www.microsoft.com/download/en/details.aspx?id=5555, 64-bit: https://www.microsoft.com/download/en/details.aspx?id=14632) You can also package it with the installer of your application. – R. Martinho Fernandes Oct 17 '11 at 05:29
  • I want to works program without installing Visual C++ Runtime . I want combine Runtime files with my program to works . – Lion King Oct 17 '11 at 05:31
  • See http://stackoverflow.com/questions/1279292/how-do-i-create-a-win32-dll-without-a-dependency-on-the-c-runtime – dalle Oct 17 '11 at 05:43
  • Is this an option http://msdn.microsoft.com/en-us/library/ms235291.aspx#sectionToggle1 ? @dalle: that only works if the code does not use any part of the runtime library. – R. Martinho Fernandes Oct 17 '11 at 05:43
  • @R.MartinhoFernandes: True, but if the program is very small and simple it could benefit from only using Win32 calls directly. – dalle Oct 17 '11 at 08:13

1 Answers1

1

That is not always a good idea, and with some libraries you may have licensing issues, but you can link everything statically, instead of dynamically.

For example, for the MS C/C++ runtime libraries (msvcp100d.dll, msvcr100d.dll), you could change the settings in the Visual Studio. Open the project properties, and go to: Configuration properties -> C/C++

change the 'Runtime library' to:

Multi-threaded Debug (/MTd)  // for a Debug build, and to
Multi-threaded (/MT)         // for a Release build

then, just rebuild your project, and it won't ask for those libraries again. As for 3rd party libraries, you'll have to have a static build of the libraries (only .lib files, as opposed to lib/dll pairs which are dynamic). Furthermore, the static libraries will have to be themselves linked statically to msvcp100d.dll and msvcr100d.dll. Once all those conditions are satisfied, you just link with those lib files, and your executable won't ask for dlls.

Amy
  • 1,814
  • 2
  • 23
  • 38