Using Macports libraries in Xcode gcc

Vince Rice vr8ce at yahoo.com
Sat Jan 10 12:07:43 PST 2009


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.


      


More information about the macports-users mailing list