On Sat, Jan 10, 2009 at 12:17 PM, Joshua Root <[email protected]> wrote:
> Vince Rice 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.
>
> Looks like you're mixing up -l and -L. The former is used like '-lpopt',
> the latter like '-L/opt/local/lib'.
>

My .bash_profile :
# Add MacPorts directories, if they exist.
if [ -d /opt/local ]; then
        export PATH=/opt/local/bin:/opt/local/sbin:$PATH
        export MANPATH=/opt/local/share/man:$MANPATH
        export C_INCLUDE_PATH=/opt/local/include
        export CPLUS_INCLUDE_PATH=/opt/local/include
        alias gcc="gcc -I/opt/local/include -L/opt/local/lib"
        alias g++="g++ -I/opt/local/include -L/opt/local/lib"
        # if [ -f /opt/local/etc/bash_completion ]; then
        #       . /opt/local/etc/bash_completion
        # fi
fi

IIRC, C_INCLUDE_PATH/CPLUS_INCLUDE_PATH alone didn't work, and thus I
added the aliases.  But now that I think about it, I should be able to
remove the former and the later should do everything on it's own.  I'm
going to try that, I think...

Naturally, YMMV/UAYOR/IANAL/etc.

-Neil.
_______________________________________________
macports-users mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-users

Reply via email to