Using Macports libraries in Xcode gcc

Mark Turner mdwturner at hotmail.com
Thu Mar 5 19:53:59 PST 2009




vr8ce wrote:
> 
> OS X 10.5.6, Macports 1.7, gcc 4.0.1 from Xcode 3.1.2
> 
> The FAQ address why Macports installs its own libraries, etc. I have the
> opposite question, and I read the FAQ and tried searching a couple of
> months of maillist archives and couldn't find it. My apologies if I missed
> it.
> 
> I have a program I want to compile that needs popt. I've downloaded the
> Macports popt package, and now have the popt.h in /opt/local/include, the
> library in /opt/local/lib, etc.
> 
> My question is what I have to do to my gcc setup to get it to "see" the
> Macport installed libraries (not just popt, but any other libraries I
> might download). I've tried adding the -I and -L's to the gcc command, and
> the popt.h is found, but it complains about the library, e.g.
> ld: library not found for -l/opt/local/lib/popt
> 
> I see that /opt/local/lib has libpopt.a, libpopt.la, and
> libpopt.0.0.0.dylib, which is similar to the other libraries. I didn't
> think I needed to specify "-L libpopt", but that gcc automatically added
> the lib prefix to the library. But, just in case, I tried adding it
> myself, but that didn't work, either.
> 
> An example command line of something I'm trying to compile:
> gcc -g -O2 -o src/ascii/ascii src/ascii/ascii.o  -l/opt/local/lib/libpopt
> 
> Please don't point out that there's a version of ascii in Macport -- I
> know that, I'm just using this as an example of trying to get a Macport
> library working in general gcc. :)
> 
> Thanks very much for your help.
> 
> 
>       
> _______________________________________________
> macports-users mailing list
> macports-users at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macports-users
> 
> 

I've had a similar problem and just figured out that I need to omit the
"lib" prefix from the library name, since GCC adds the prefix. Now ... it's
been a while since I've dabbled with the C linker let alone GCC, but has
this always been the convention? Why in the world would linker insist on
changing a file name, by adding a prefix or anything else? Seems weird, and
it's taken me several hours to figure out .... d'oh!

 
-- 
View this message in context: http://www.nabble.com/Using-Macports-libraries-in-Xcode-gcc-tp21392095p22365821.html
Sent from the MacPorts - Users mailing list archive at Nabble.com.



More information about the macports-users mailing list