Help save net neutrality! Learn more.
Close

#30 Linking error for win32 compilation on x64 platform

Bug
closed
nobody
None
5
2014-08-23
2010-12-22
Anonymous
No

Platform: Vista x64
Compilation: win32

I'm sucessfully running scons to get core.lib, with flag CPPDEFINES = ["DEBUG"]
Then when I build cgkit, I get the following link error:
core.lib(vec3.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

This makes me think that somehow, core.lib was compiled in x64, which is strange because there's only -DWIN32 in the compile command line.

I tried to force the x86 architecture in scons by using:
DEFINES_X86=[ '"x86"', '"_X86_"', '"_i386_"' ]
env.AppendUnique(CPPDEFINES=DEFINES_X86)

Then I've got a compile error when running scons:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winnt.h(81) : fatal error C1189: #error : "No Target Architecture"
That is really strange because that message can be displayed only in the case #if defined(_WIN64)

So what happens here, who defines _WIN64 in my back?

Thanks
-David

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2010-12-22

    I'm building cgkit with:
    python_d setup.py build --debug

     
    Last edit: Anonymous 2013-11-21
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-01-17

    I found the reason of the issue so I'm posting it here in case it can help someone else.

    In fact, using the "WIN32" macro isn't enough to build a 32 bit version on a 64 bit OS. It's good for the compiler, but SCONS needs also to be told that it is targetting a 32 bit architecture.

    When initializing its environment, SCONS builds a (HOST_ARCH, TARGET_ARCH) tuple, that is inferred from the computer architecture if nothing explicitly defined. This influences the path where SCONS will look for Windows SDKs libs for instance.

    As I have a 64 architecture, by default SCONS builds a environment (x64, x64) when calling in setup.py:
    env = Environment(options = opts)

    So I need to explicitly tell him that I'm targetting a 32 bit build:
    env = Environment(options = opts, TARGET_ARCH='x86')

    This probably could be an option of setup.py

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-01-17
    • status: open --> closed
     

Log in to post a comment.