As is asked and answered in this post, I needed to give -arch i386 option for SWIG/C# integration.
开发者_StackOverflow社区Do I need to give the option for both compilation/link?
g++ -c -arch i386 example.cxx example_wrap.cxx
g++ -arch i386 -bundle -undefined suppress -flat_namespace example.o example_wrap.o -o libexample.dylib
Have you tried it? A simple test with a C program on OS X 10.6 with a 64-bit capable machine suggests that, in general, you do need to specify -arch
for both.
$ gcc -arch i386 -o x.o x.c
$ gcc x.o -o x.dylib
ld: warning: in x.o, file was built for i386 which is not the architecture being linked (x86_64)
Intuitively, the linker does need to know which set of architecture-specific libraries to link with.
精彩评论