CPATH versus -I

Ryan Schmidt ryandesign at macports.org
Thu Jun 17 21:57:24 PDT 2010


On Jun 17, 2010, at 23:22, Dan Ports wrote:

> On Thu, Jun 17, 2010 at 10:46:55PM -0400, Michael Dickens wrote:
>> When should I be
>> using CPATH=<PATH:LIST> versus "-I<PATH_1> -I<PATH_2> -I..."?  Is there
>> any difference between them, maybe search order?  When is one preferable
>> to the other?  Is their interpretation compiler dependent?
> 
> CPATH is searched after -I options provided on the command line, but
> before -isystem options. There's also C_INCLUDE_PATH, which is searched
> after -isystem directories.
> 
> It makes sense to use one of these options (CPATH, C_INCLUDE_PATH, or
> -isystem) instead of -I to add $prefix/include, since they're searched
> after any -I flags the program specifies. This keeps the program's
> include files from being shadowed by identically-named files in
> $prefix/include.
> 
> I think this is probably the cause of at least some of qt4-mac's build
> conflicts. With libevent active, it sounds as though something is doing
> a #include <Event.h> and getting libevent's /opt/local/include/event.h
> instead.
> 
> I see that by default base both sets CPATH and adds -I flags to CFLAGS.
> Not sure why we do that. It seems like the right thing to do would be
> to rely on CPATH alone, or change -I to -isystem. Is there a reason not
> to do this? (I found a couple of old messages suggesting this, but not
> much discussion.)

Based on your explanation, yes, it sounds like we should do one of those things instead of what we're doing now. Somebody should do this, then try to install a whole bunch of ports and see if they work.



More information about the macports-dev mailing list