Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling 32-bit application using Visual Studio on a 64-bit machine

I'm trying to compile a simple 32-bit Hello World application written in C using Visual Studio 2010 on a 64-bit machine on a Windows 7 fresh install. I also installed the "Windows SDK for Windows 7 and .NET Framework 4" after installing Visual Studio. I built the application selecting "Win32" as platform. It works on Windows 7 but if I run the application on my 32-bit machine with Windows XP Professional (fresh install also this, without softwares and Service Packs) it seems not working getting this error:

"This application has failed to start because msvcr100.dll was not found"

If it can be useful Dependency Walker detects 2 errors (see the linked picture for details):

"Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module."
"Error: Modules with different CPU types were found."

http://img820.imageshack.us/img820/4725/errordp.png (PIcture)

How can I solve it? Thanks!

like image 909
mt22 Avatar asked Aug 11 '11 15:08

mt22


2 Answers

The machine on which it is run needs the runtime libraries. See this MSDN information.

like image 177
Mark Wilkins Avatar answered Sep 30 '22 07:09

Mark Wilkins


Don't trust Dependency Walker on this... It clearly shows your exe is 32 bit. Your problem is with the VC redistributables, which are the CRT dlls - look for vcredist_x86.exe in your VS installation. You should run it before you run your app.

Another option is to statically link the CRT. See the /MT option. Will make your exe larger, but save the vcredist stuff.

like image 27
eran Avatar answered Sep 30 '22 07:09

eran