views:

1749

answers:

7

I've got a minimal app I just created, using VS 2008 SP1 on Vista x64. Its a Console app, created with the wizard, no MFC or anything, I'm building it in 64bit.

When I run the debug exe, on my development box, by pressing F5 in Visual Studio 2008, I get this error:

TestApp.exe - Unable To Locate Component

This application has failed to start because MSVCR90.dll was not found. 
Re-installing the application may fix this problem. 

OK

I don't get this error when I run the release exe, it works as expected.

This problem started when I added some include dependencies on iostream and fstream and started calling some winsock API calls.

Any suggestions?

UPDATE: I copied msvcr90.dll (not msvcrd90.dll) into the correct folder, and now I get a different error:


Microsoft Visual C++ Runtime Library

Runtime Error!

Program: [snip]...

R6034

An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information.


OK

  • Alex
+5  A: 

You application is using the DLL CRT runtime. The machine you want to run it on requires the installation of the debug CRT runtime dll's (which is a pain in the ass...). I think the better solution is to change the compile options to use the static linked CRT runtime (that means the runtime is linked into your application instead of using the DLL version).

In visual studio go into the Properites for your project then select the Configuration Properties / C++ / Code Generation and change the "Runtime Library" from "multi-threaded debug dll" to "multi-threaded debug".

You may like to do the same for the release build as well because some versions of the OS will not come with the V9 release CRT libraries pre-installed, or you can include the v9 release crt dll as part of your install.

Shane Powell
Hi, thanks for the ideas.The machine I want to run it on is my development box, I am running it in the IDE by pressing F5.I changed the "Runtime Library" to "multi-threaded debug" and it no longer links, I get about 7 errors like:Error 13 error LNK2005: memmove already defined in LIBCMTD.lib(memcpy.obj) MSVCRT.lib DataEngineSocketsAPI
Alex Black
A: 

The Debug exe is linked to the headers for the debug runtime library, MSVCR90D.dll. You need to make sure that dll is in the path. Static linking is, as Shane says, a viable option, but the typical solution is to deploy the dependant dlls with the exe. Statically linking everything leads to bloated exes and lots of duplicated copies of runtime libraries.

Seeing your edit, the problem is certainly the msvcr90d.dll, but it needs to be deployed correctly in the WinSXS folder. You might be able to re-install the service pack for VS 2008 and get it to redeploy.

Robert
Hi Robert, given I am using VS2008 shouldn't MSVCR90D.dll be in the path already?
Alex Black
Make sure that path is in Tools->Options->Projects and Solutions->VC++ Directories.
djeidot
Searching my PC, I find it in these locations:1. C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\dll\[architecture] (e.g. armvi,x86, etc)2. C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist\[architecture]\Microsoft.VC90.DebugCRT3. Folders like:C:\Windows\winsxs\amd64_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_4ec74c6b3093419c
Alex Black
djeidot: which directory should I be pointing to? (see choices in my previous comment. Which set of directories do I add this to? Includes? no. Libraries? no.. ?
Alex Black
its complaining about "MSVCR90.dll" not "MSVCR90D.dll"... even though I'm doing a DEBUG build.
Alex Black
you can examine the exe with depends and find our exactly what dll it wants
Robert
A: 

How are you running the release exe (Ctrl+F5 in the IDE)? You should set the Runtime Library to the same thing you are setting the release exe.

Dolphin
Either Ctrl+F5 or just F5. Runtime Library for release is set to "Multi-threaded DLL (/MD)" and for debug is set to "Multi-threaded Debug DLL (/MDd)"
Alex Black
A: 

Are you linking your debug mode program to a release mode library? You mention this error in a comment:

Error 13 error LNK2005: memmove already defined in LIBCMTD.lib(memcpy.obj) MSVCRT.lib DataEngineSocketsAPI

What that looks like to me is you have a library named DataEngineSocketsAPI that links to MSVCRT.lib, which defines memmove(). But, your exe links to libcmtd.lib, which also defines a different (debug mode) version of memmove().

Third-party (e.g. your own) libraries must have debug and release versions too, and you must use the one appropriate to the mode you're building your exe for.

Rob K
I just one one project, its an exe, no dlls or libraries involved. Just a single thing. Perhaps the DEBUG project configuration is not setup correctly somehow.
Alex Black
Where's the DataEngineSocketsAPI reference coming from, then?
Rob K
A: 

Thanks again for all the help with this. It turns out I'd just made a mistake and not noticed that a library I was using was statically linked against a different version of the MSVC runtime. That was causing on end of problems.

Alex Black
A: 

See this link

http://www.insidercoding.com/post/2008/07/21/Debugging-issues-with-MSVCR90DLL.aspx

You need (for debug mode only) to ignore on the link input tab MSVCRT; MSVCR90; as you want to be using the debug version of the CRT.

A: 

I can confirm this problem: letting Visual Studio 2008 create the project (Visual C++/Win32 Console Application) and pressing F5 will display that error.

There is a simple solution:

Turn incremental linking off. HOWTO: open properties page for the project. Set Configuration Properties/Linker/General/Enable Incremental Linking to "No (INCREMENTAL:NO)".

Peter Mortensen