Wednesday, March 24, 2010

crossdev on gentoo and pkg-config

I was trying to link against libraries on gentoo for windows. Using mingw32 and the crossdev tools made things easier, but they were not too smooth. One of the problems was getting pkg-config prefix.
For example:
I wanted to link against dbus, so in my makefile I should use:

LIBS=$(shell pkg-config --cflags --libs dbus-1)

For none cross compile, this would work, however, for cross compile this is not the case.
Refering to the :http://en.gentoo-wiki.com/wiki/Crossdev

I crated a script in /usr/bin/i686-mingw32

#!/bin/sh
SYSROOT="/usr/i686-mingw32"
export PKG_CONFIG_LIBDIR="${SYSROOT}/usr/lib/pkgconfig"
unset PKG_CONFIG_PATH PKG_CONFIG_ALLOW_SYSTEM_CFLAGS PKG_CONFIG_ALLOW_SYSTEM_LIBS
exec pkg-config "$@"
but things didn't work as expected: 
 
03:23:39 @ test $ i686-mingw32-pkg-config --cflags dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include 
hum, still pointing to the wrong one !
logged in as root, and :
mars ~ # cd /usr/i686-mingw32/usr/lib/pkgconfig/
mars pkgconfig # sed 's/prefix=\/usr/prefix=\/usr\/i686-mingw32\/usr/g' -i *.pc
logged in as a user again, and:
03:31:06 @ test $ i686-mingw32-pkg-config --cflags dbus-glib-1
-I/usr/i686-mingw32/usr/include/dbus-1.0 -I/usr/i686-mingw32/usr/lib/dbus-1.0/include -I/usr/i686-mingw32/usr/include/glib-2.0 -I/usr/i686-mingw32/usr/lib/glib-2.0/include  
Wonderfull, pointing to the right place. 

No comments:

Post a Comment