Subject: Re: PKGCONFIG_OVERRIDE only for buildlinking (not for installed *.pc
To: Thomas Klausner <wiz@NetBSD.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 03/02/2006 17:22:56
On Fri, 3 Mar 2006, Thomas Klausner wrote:

> On Thu, Mar 02, 2006 at 02:24:00PM -0800, Jeremy C. Reed wrote:
> > Should we be "Adding rpaths to pkgconfig files" for the *pc files that are 
> > actually installed?
> 
> No, I don't think so.

Your reply here differs from your final sentence below ...

> > For example, I am building an Xorg application without using pkgsrc build 
> > system. But I am using the pkgsrc provided freetype2 and fontconfig and 
> > pkg-config. Because the -Wl,-R${libdir} was added, it overrode my choice 
> > for other libraries due to the pkgconfig --libs ordering (and used my 
> > incompatible old pkgsrc libraries).
> 
> If you use the pkgsrc foo.pc file, you should use the corresponding
> pkgsrc foo libs.

Understood. And I do want to use the corresponding libraries.

> If you want to use non-pkgsrc foo.pc, you should set the PKG_CONFIG_PATH
> correctly.

Understood. In my case, I am using some libraries from my non-pkgsrc and 
some from pkgsrc.

The problem is that pkg-config --libs ordering seems to force the use of 
libraries from pkgsrc even when I don't want to use them.

When I remove the -Wl,-R${libdir} from the Libs: line from my pkgsrc *pc 
files, then it correctly uses the correct libraries.

But then I have the problem where it doesn't see the libraries at run-time 
as you mention here:

> I prefer the current way (as it is) because I can compile and install
> software outside of pkgsrc without having to add -Wl,-R in lots of places.
> I think this should stay as-is.

Maybe the problem is not in pkg-config itself, but the use of it that I am 
seeing.

Here is an example:

gcc -I/home/reed/xorg/include -I/home/reed/xorg/include 
-I/home/reed/pkg/include -I/home/reed/pkg/include/freetype2 
-I/home/reed/xorg/include -I/home/reed/xorg/include -g -O2 -o x11perf 
bitmaps.o do_arcs.o do_blt.o do_complex.o do_dots.o do_lines.o 
do_movewin.o do_rects.o do_segs.o do_simple.o do_tests.o do_text.o 
do_traps.o do_tris.o do_valgc.o do_windows.o x11perf.o 
-L/home/reed/xorg/lib -lXext -Wl,-R/home/reed/pkg/lib 
-L/home/reed/xorg/lib -L/home/reed/pkg/lib -lXft -lXrender -lfontconfig 
-lfreetype -lz -lX11 -L/home/reed/xorg/lib -lXrender -lX11 
-L/home/reed/xorg/lib -lXmuu -lX11 -lm

The above fails for me, because the "-Wl,-R/home/reed/pkg/lib" which came 
from the pkg-config --libs xft. This causes the wrong and old libX11 to be 
used (causing an undefined reference).

I want the above to use fontconfig and freetype as installed via pkgsrc 
(/home/reed/pkg/lib). And for all X libraries use my new versions 
(/home/reed/xorg/lib). Any ideas on how the above should be ordered? (I 
have tried a few different ways with no luck. The only way that does work 
for me is to remove the "-Wl,-R/home/reed/pkg/lib".)

My workaround is to remove all the libraries and pc files for the 
identical software. But I prefer not having to do that. And I prefer not 
having two installations of pkgconfig, freetype2, fontconfig.

 Jeremy C. Reed

 	  	 	 technical support & remote administration
	  	 	 http://www.pugetsoundtechnology.com/