0

I am using Mac OS X 10.8.2 and I am compiling my code using the scons compiler. I am using the 32 bit xerces-c database version 2.8.0.

when I am trying to build I get errors:

$scons

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...

ld: warning: ignoring file /usr/xerces-c_2_8_0-x86-macosx-gcc_4_0/lib/libxerces-c.dylib, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /usr/xerces-c_2_8_0-x86-macosx-gcc_4_0/lib/libxerces-c.dylib

ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
scons: *** [wntevo] Error 1
scons: building terminated because of errors.

I checked my libxerces-c.28.0.dylib file:

$file libxerces-c.28.0.dylib 
libxerces-c.28.0.dylib: Mach-O dynamically linked shared library i386

What should I add to my SConstruct file to make it build in i386 on a x86_64 machine?

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
anibio
  • 1
  • 1
  • 1
  • 6
    scons is not a C++ compiler. – Lightness Races in Orbit Jan 07 '13 at 13:44
  • We could better help if you show us the SConsctruct. Sounds like you are trying to compile a 32 bit application with a 64 bit library. – Brady Jan 07 '13 at 14:04
  • What I know about scons would fit on a postage stamp... But I assume there is something like a makefile, and in it you can probably specify flags, and passing the -m32 (I think... Don't quote me.) will force the compiler into 32 bit mode, else maybe i386 arch can be specified... Something like that – Grady Player Jan 08 '13 at 06:01

2 Answers2

1

To clarify, SCons is not a compiler it is a build tool. You are using SCons to invoke the compiler, and you let SCons take care of the details of how to build your application from the source you are editing.

Your problem now is that SCons cannot help you with a detail. You need to tell SCons to create an environment that lets it compile a 32 bit application. This is done by passing the a flag to the compiler, which instructs it to compile a 32 bit application.

I guess that your compiler is gcc and it needs the flag -m32 to compiler correctly. To do this you can tell SCons to tell this to the compiler.

Somewhere in the SConstruct file you will find a call that create an Environment() or that invoke the builder Program() If you find both, you would like to alter the environment that is used to create the program. So if your code says env = Environment(...) and later on env.Program(...) you want to change the Environment line to add this argument:

env = Environment(...other arguments..., CPPFLAGS=["-m32"])

you invoke the program builder like this:

Program(...0 or more arguments...)

you need to change it to:

Program(...0 or more arguments..., CPPFLAGS=["-m32"])

This change should be visible when you run SCons, as you should see the option -m32 among the arguments to g++.

As a side note, to prevent more confusion about compilers and build tools I suggest you read a bit about SCons, a good start could be the man pages

daramarak
  • 6,115
  • 1
  • 31
  • 50
-1

This is what I use to compile on 32-bit arch when I want to in scons

env = Environment(TARGET_ARCH = 'x86')

David Tr
  • 151
  • 2
  • 9
  • 1
    As far as I know (and I wrote the code), TARGET_ARCH currently only works for windows with visual studio and not other platform or compiler. Since the author is asking about building on MacOSX. This answer is incorrect. – bdbaddog Jul 31 '15 at 23:23