How do I compile GCC on OS X?
March 4, 2006 8:10 AM   Subscribe

When compiling gcc-3.4.4 on OS X 10.4.5 I get an error about an undefined symbol, _fprintf$LDBLStub. How do I make this go away?

Google shows that this is a really common problem. However, I can't seem to find a solution that works for me.

The two suggestions I see the most are to use GCC 3.3 (gcc_select 3.3) and/or to include -lSystemStubs for linking. I've tried with both the GCC 3.3 and GCC 4.0.1 compilers on my system, same results with either. I'm a bit wary about the -lSystemStubs suggestion since this is GCC (I find it more intimidating than most programs). Also, it takes a long time to build and I'm not exactly sure how to make sure it uses that library (just set LDFLAGS?).

I need to compile this for myself and I do need GCC 3.4.4. So I'm not looking for binaries or different versions of GCC. I know other OS X users have gotten this to build but I'm not sure exactly how, but I do know it's possible.
posted by mto to Computers & Internet (7 answers total)
 
-l option means to include a library, ie SystemStubs.
It will look in your LD_LIBRARY_PATH for it, or you can type -L(specific directory where SystemStubs lives). if you do:
find . -name "*SystemStubs*"
at the top level of your computer, you should find where it lives on your machine (if it does). If it's in a normal place (like /usr/lib or /usr/local/lib or something) then your LD_LIBRARY_PATH should find it when you try to compile.
If it doesn't, you need to install the library.
(Note: I am not an OS X user, just a linux/unix user, but I've fussed around with OS X and these commands should work the same on both)
posted by j at 8:29 AM on March 4, 2006


Response by poster: Perhaps a clarification is in order. I'm either looking for a way to configure my system so I don't need to do anything special to build GCC 3.4.4 or I'm looking for confirmation that linking in SystemStubs is exactly what I need.

I am assuming here the GCC folks are smarter than me and that if SystemStubs was needed they would've thought to add it. Even if they didn't add it to their build procedure I'd expect to find instructions on the Web about other folks who've tackled this issue WRT GCC. However, I can't find any GCC specific instructions.

This leads me to believe the problem is that my system is not configured correctly. I don't really want to mess with linking in SystemStubs unless someone with more experience can assure me that that's just life on OS X.
posted by mto at 8:46 AM on March 4, 2006


Sorry - it's early here ..
I meant to say, if the file doesn't exist on your machine you need to install the library.
Anyway, make a unmodified copy of your Makefile where LDFLAGS or LIBS lives ( I assume if this is a big install, there is more than one Makefile but it's usually the one in the current directory -- looking at the google search, it appears to be Makefile.common).
Inside the Makefile, append -lSystemStubs to the end of the LIBS or maybe LDFLAGS declaration.
follow the directions of the install.

(the symbol that is undefined appears to be defined in the SystemStubs library (your google search shows that), so I think this is what you want to do -- and you always have the backup copy of the Makefile in case your modification doesn't work. )
posted by j at 8:46 AM on March 4, 2006


Don't assume anything when it comes to installing *nix software. What works on their setup may not work on yours. The google search you did shows that adding that -lSystemStubs has worked for others, so you should definitely try it.
Also, I'm wondering if you have it installed at all or it's not in a standard location on your machine (which is why I suggested to try find/-L(dir where it lives)). Check that first.
While I can't assure you that "that's just life on OS X", I can definitely assure you that it's EXTREMELY common to tweak makefiles for a gcc compile to work correctly on your individual setup.
posted by j at 8:52 AM on March 4, 2006


I am assuming here the GCC folks are smarter than me and that if SystemStubs was needed they would've thought to add it.

There's your problem right there. The GCC folks don't really care about OSX because it's Apple's job to make the compiler work on Apple's platform. In fact, Apple makes many modifications to GCC, which is why they host their own distribution. The first paragraph from the README.Apple file:

This file describes Apple's version of GCC 3.x modified for Darwin / Mac OS X. Although Apple's stated policy is to contribute all of its GCC work to the FSF GCC mainstream, at any given moment there will be changes that are permanently unacceptable for FSF GCC, in need of rework before acceptance, or that we simply aren't ready to send in. This version of GCC contains all those changes.

So I'd say that if adding -lSystemStubs works then you should do it. By far the most worrisome thing is that you're trying to use a non-Apple version of GCC to compile your Apple software.
posted by sbutler at 11:37 AM on March 4, 2006


mto -- did you at least try it? Let us know how it went.
posted by j at 10:52 AM on March 5, 2006


Well, if I "nm /usr/lib/libSystemStubs.a" on a 10.4.3 system, I can see that it does include the symbol _fprintf$LDBLStub (along with a bunch of similar ones). So adding -lSystemStubs should fix that error message. Whether it fixes the underlying problem, I don't know --- I have no idea what those stubs are for, or why compiling gcc generates references to them.
posted by hattifattener at 11:41 AM on March 5, 2006


« Older Où sont mes blogger posts d'antan?   |   SteamVac needs some fixing Newer »
This thread is closed to new comments.