how to handle differing compilers?

Rick Jones rick.jones2 at hp.com
Mon Apr 3 11:32:52 PDT 2006


Hi -

I have been making use of pkg-config in netperf4:

http://www.netperf.org/svn/netperf4/branches/glib_migration

(for those with a keen desire to critique code :)

to get the cflags and libs one should use when linking against stuff 
like libxml2 and glib.  When the compiler used to compile libxml2 and 
glib is the same as the compiler being used to compile netperf4, all is 
happiness and joy.

However, there are times when the compiler used to compile netperf4 is 
not the same compiler used to compile libxml2 and glib.  In particular, 
under HP-UX I presently compile netperf4 with the HP ANSI C compiler, 
but I grab libxml2 and glib bits from http://hpux.connect.org.uk/ where 
they are presently using gcc.

Most of the options are the same, but stuff like "-pthread" is an option 
that the HP ANSI C compiler does not grok as it is a gcc-ism (IIRC). 
Based on the look of the error messages, the HP compiler thinks it is a 
-p option and then a poorly formed -t option.

For the time being, I've been kludging things by using the "only" 
options in pkg-config, but am concerned about the "other" options that 
may be being left behind.  At first I thought it might simply be the 
-pthread and I could say in my configure script that if the compiler was 
gcc I should just add a -pthread to the CFLAGS and LIBS.  However, when 
I started compiling on OSX 10.3.9 with gcc 3.3 (from Apple) that 
compiler seems to not grok the -pthread option either - although 
thankfully it only warns it doesn't abort.

So, I'm seeking collective wisdom as to how best to address this - if I 
should keep using the "only" options and special-case exceptions, or if 
there might be something a bit more general?  Is there a way to get 
pkg-config to say what compiler was used to compile the package?

thanks,

rick jones
-- 
portable adj, code that compiles under more than one compiler
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...


More information about the pkg-config mailing list