Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rate Thread Display Modes
Old 11-07-2009, 10:35 PM   #1
reakin
Prospect
 
Join Date: Oct 2009
Posts: 11
gcc is building for wrong architecture

Hi list,

I recently moved from a linux-based machine to a macbook and I am trying to compile some plugins I made for various programs. Gcc is however building my plugins for the wrong architecture. I'm not sure how to debug this, but I get errors like (for a Pure Data external):

/Users/richardeakin/pd/reakin/incr/incr.pd_darwin: mach-o, but wrong architecture

and (for a python module):
gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc -arch x86_64 build/temp.macosx-10.6-universal-2.6/pysms_wrap.o -L../src -L/opt/local/lib -lsndfile -lgsl -lgslcblas -lsms -o _pysms.so
ld: warning: in /usr/local/lib/libsndfile.dylib, file is not of required architecture
ld: warning: in /opt/local/lib/libgsl.dylib, file is not of required architecture
ld: warning: in /opt/local/lib/libgslcblas.dylib, file is not of required architecture
ld: warning: in ../src/libsms.a, file is not of required architecture
ld: warning: in /usr/local/lib/libsndfile.dylib, file is not of required architecture
ld: warning: in /opt/local/lib/libgsl.dylib, file is not of required architecture
ld: warning: in /opt/local/lib/libgslcblas.dylib, file is not of required architecture
ld: warning: in ../src/libsms.a, file is not of required architecture


I installed Xcode from the manufacture's disk and I don't know how I set this up wrong. As I am using scons for the first plugin and python's distutils for the second, I would think they could figure out I was on an intel mac and build appropriately.

Anyone have suggestions? Thanks

Rich
reakin is offline   Reply With Quote
Old 11-08-2009, 08:59 AM   #2
fracai
All Star
 
Join Date: May 2004
Posts: 911
It could be that some component has been built for 32 bit and what you're trying to compile now is targeted for 64 bit. Under MacPorts I try to install everything as 32 / 64 bit universal to avoid these problems. MacPorts may be able to help in some cases by building one of your dependencies this way. It then wouldn't matter which architecture your build was targeting.
fracai is offline   Reply With Quote
Old 11-08-2009, 12:20 PM   #3
reakin
Prospect
 
Join Date: Oct 2009
Posts: 11
I think I understand the problem then.. my application is 32bit, but gcc is compiling my plug-ins as 64bit. I am not sure, however, anyone know of a way to check these type of things? Also, is there a way to check if the libraries I have installed are 32, 64bit, or universal?
reakin is offline   Reply With Quote
Old 11-08-2009, 06:50 PM   #4
reakin
Prospect
 
Join Date: Oct 2009
Posts: 11
So, the problem is that my system is building x86_64 type binaries, when the application I have is compiled for i386. I'm now realizing what you mean by getting MacPorts to give you universal binaries (how do you specify this, by the way?), but I can't get my own compiled code, or libraries compiled from source, to compile as i386. I suppose the ALL have to be i386 for the end plugin to work.

Any advice is welcome... still new to this world of programming.
reakin is offline   Reply With Quote
Old 11-08-2009, 09:40 PM   #5
fracai
All Star
 
Join Date: May 2004
Posts: 911
For MacPorts you can either use the universal variant for relevant ports, or set it as a default variant by editing /opt/local/etc/macports/variants.conf

For setting the arch you want to compile, I'd start with either some searches or reading some MacPorts portfiles. Or installing something under MacPorts with a specific arch using the debug flags. I'm sure searching would provide better info on archs.
fracai is offline   Reply With Quote
Old 11-08-2009, 10:09 PM   #6
reakin
Prospect
 
Join Date: Oct 2009
Posts: 11
Thanks for the tips on Macports. I found that if I type something like
Code:
sudo port install libsndfile +universal
Then I will get a universal binary that works in either case.

But, what I can't seem to figure out is how to compile my own plugins as i386, in order to match my app that can only be compiled in 32bit (by the way, i've been searching the net the entire day so far on how to do this). All I can find is that I should have to specify the flag '-arch i386' to gcc, but the linker complains that this is the wrong architecture and just builds the x86_64 version anyway.

Dunno..
reakin is offline   Reply With Quote
Old 11-09-2009, 12:16 PM   #7
reakin
Prospect
 
Join Date: Oct 2009
Posts: 11
Ah, found out that I need to specify it to the linker too. That part is solved..
reakin is offline   Reply With Quote
Reply

Tags
gcc wrong architecture

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:09 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.