views:

460

answers:

4

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?

+1  A: 

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

Chris Doggett
Where? I don't see any tabs or any section called Build. In the Properties | Linker | Advanced options, Target Machine is set to MachineX86.
Wannabe Tycoon
Probably different properties for C++ solutions than C#. What other ones are available?
Chris Doggett
For the linker options, that's the only option that looks related.
Wannabe Tycoon
Look for the build options, because it looks like the library is being compiled as x64, but tries to link as x86. I don't have Visual C++ installed on this machine, only C#. I'll look when I get home.
Chris Doggett
I think you may be right. I just figured out DUMPBIN and inspected the COFF information. The file header of one .obj reports "8664 machine" (x64) as the machine.
Wannabe Tycoon
A: 

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.

Wannabe Tycoon
A: 

Hi Wannabe Tycoon,

Were you able to figure out what the problem was. I am stranded with a similar issue and see that there is not much information available on internet about this. What compiler did you use to build? I am trying to use the cross compiler $(VCInstallDirs)bin\x86_amd64. My host machine is x64 running XP and target is x86. I get exactly the same error message as you got except that the object file is the very first object file the linker is trying to link. As you have also mentioned I have the advanced linker option /MACHINE set to x86.

Can you copy contents of your tools-->options-->VC++ Directories (Executables, includes and libs) here? I mostly need to see what compiler you are using and what windows SDK you are using.

Thanks much in advance.

knight
A: 

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.

knight