Building x86 code in an x64 (Visual Studio 2008) Environment


I want to build a library (poco-1.3.6p2-all, for what it's worth) for x86. I just set up a new (clean) Windows 7 64 bit machine and I installed Visual Studio 2008 Standard. Nothing installed up to now on this box has had an installation error.

The same library has built flawlessly on a Windows XP 32 bit system with VS 2008 Standard installed. Oh, yeah, it's all unmanaged C++.

The error I am getting is at every link of the individual DLLs in the project. Example:

1>.\obj\debug_shared\CppUnitException1.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

The library in question is built from a .vcproj file invoked from a .cmd file build script.

The compiler options (command line) look like:

/Od /I "include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "CppUnit_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_VC80_UPGRADE=0x0710" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /GF /FD /EHsc /RTC1 /MDd /Fo".\obj\debug_shared/" /Fd".\obj\debug_shared/vc80.pdb" /W3 /nologo /c /ZI /errorReport:prompt

The linker command line in the project options looks like:

/OUT:"..\bin\CppUnitd.dll" /INCREMENTAL /NOLOGO /DLL /MANIFEST /MANIFESTFILE:".\obj\debug_shared\CppUnitd.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"..\bin\CppUnitd.pdb" /DYNAMICBASE /NXCOMPAT /IMPLIB:"..\lib\CppUnitd.lib" /MACHINE:X86 /ERRORREPORT:PROMPT

It appears (to me) that the linker sees x86 object files, but is being invoked in x64 mode even though the command line option is correct.

I need the target to be a 32 bit/x86 type, not x64.

Is there some Visual Studio option that will fix this?

Best Solution

Right click the project in VS, go to properties. Find the Build tab, and make sure "Platform target" is set to "x86".

Related Question