Wannabe Tycoon
Wannabe Tycoon

Reputation: 307

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?

Upvotes: 1

Views: 5535

Answers (4)

ceyun
ceyun

Reputation: 381

I have a solution but maybe that cannot solve your problem.

Now, my way to solve same problem is

(in Visual Studio) Project -> Properties  ->  C/C++  ->  Optimization  ->  Inline Function Expansion =  Default

I did it and my problem has solved.

Upvotes: 0

knight
knight

Reputation: 11

Well I wanted to answer it earlier but did't get a chance to. So the issue was with my Visual Studio installation. Somehow the installation did't install compiler for x86 and a couple of related dlls. Once I reinstalled it worked. And also the correct compiler to use would be x86 and not the cross compiler.

Upvotes: 1

Wannabe Tycoon
Wannabe Tycoon

Reputation: 307

I think I should put this question to bed. I fiddled with some things in the system configuration (like the path variable) and subsequent builds went correctly, IE, I wound up with 32 bit OBJ files which linked into DLLs properly.

I am not certain what changed that influenced the build.

So, a full build from "clean" works now, but I don't know exactly what I changed that made it work. I was frazzled after rebuilding my system (hardware included) from scratch and reinstalling everything. So possibly I was omitting something obvious and stupid (like the "vsvars32" invocation before the build) and the make file was accommodating me with undesirable defaults.

Upvotes: 1

Chris Doggett
Chris Doggett

Reputation: 20737

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

Upvotes: 1

Related Questions