pkgconfig


Forum: Extension Development
Topic: pkgconfig
started by: Juanito

Posted by Juanito on May 08 2008,09:26
Quote
Just to get even more off-topic.... what do you do when pkg-config fails as it can't find the .pc files? I have been trying to compile the lastest gtkam & running into numerous problems with  pkg-config when executing the configure scripts for gtkam, gphoto & the libraries they depend on (e.g. libexif etc).


I guess the first thing is to check that the format of the pkgconfig variable is correct, eg:
Code Sample
$ export PKG_CONFIG_PATH=/opt/myapp1/lib/pkgconfig:/opt/myapp2/lib/pkgconfig:/opt/myapp3/lib/pkgconfig


If this doesn't work (and sometimes it doesn't even when the pc files are present), then there are a couple of other options:

1. set compiler and library flags, eg:
Code Sample
$ export CPPFLAGS="-I/opt/myapp1/include -I/opt/myapp2/lib"
$ export LDFLAGS="-L/opt/myapp1/include -L/opt/myapp2/lib"


2. set ./configure switches if possible, eg:
Code Sample
$ ./configure --prefix=/opt/myapp --xincludes=/opt/myapp/include --xlibs=/opt/myapp/lib


3. set other environment variables (usually listed by ./configure --help) eg:
Code Sample
$ export XMLCFLAG=-I/opt/myapp/include
$ export XMLLDFLAG=-L/opt/myapp/lib


4. (if the ./configure script completes) edit the Makefile(s) directly to add the location of headers/libs

5. (last option, since this is not a good idea) symlink the appropriate headers and libs to /usr/include and /usr/lib

Posted by andrewb on May 09 2008,02:43
OK,

I've gone back to the start with compiling gtkam, with the latest downloads of gtkam, libgphoto2, libexif, libexif-gtk & libusb.

I use the compile -3.3.5.uci & gtk+-2.10.9.unc & gtk+-2.10.9.unc extensions loaded onto an otherwise base frugal install of DSL 4.3.

I can compile & install libusb & libexif, but when compiling libexif-gtk the  configure script exits with the following:

Code Sample


config.status: creating po/Makefile
./configure: line 1: srcdir: command not found


Configuration (libexif-gtk):

       Source code location:    
       Version:                 0.3.5
       Compiler:                gcc

       libexif:                 < 0.6.12 (think about upgrading)


dsl@box:/mnt/hda/libexif-gtk-0.3.5$


but make then fails with:

Code Sample
/bin/sh ../libtool --mode=link gcc  -g -O2 -Wall -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith   -o libexif-gtk.la -rpath /usr/local/lib -version-info 5:0:0 gtk-exif-browser.lo gtk-exif-content-list.lo gtk-exif-entry.lo gtk-exif-entry-ascii.lo gtk-exif-entry-copyright.lo gtk-exif-entry-date.lo gtk-exif-entry-generic.lo gtk-exif-entry-flash.lo gtk-exif-entry-number.lo gtk-exif-entry-option.lo gtk-exif-entry-rational.lo gtk-exif-entry-resolution.lo gtk-exif-entry-user-comment.lo gtk-exif-entry-version.lo ../gtk-extensions/libgtk-extensions.la -L/usr/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lexif -lm  
libtool: link: cannot find the library `/usr/lib/libXrender.la'
make[2]: *** [libexif-gtk.la] Error 1
make[2]: Leaving directory `/mnt/hda/libexif-gtk-0.3.5/libexif-gtk'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/hda/libexif-gtk-0.3.5'
make: *** [all] Error 2
dsl@box:/mnt/hda/libexif-gtk-0.3.5$


libXrender seems to be in /usr/X1R6/lib. I've created a symlink to /usr/lib, but it doesn't seem to make any difference. (there is no ".la" file there - just the .so.1.2 file & a symlink to it in .so.1)

Posted by Juanito on May 09 2008,04:05
Quote
libXrender seems to be in /usr/X1R6/lib

- I don't think libXrender is in the base dsl, did it come from an old version of gnu-utils or XFree86 maybe? This being said, this is the first time I saw an error complaining of missing the *.a version of a library.

As a test, you could try loading the latest xorg72.uci (the headers/pc files are in it),  including it in PKG_CONFIG_PATH and trying again to compile.

Posted by ^thehatsrule^ on May 09 2008,05:08
A response (from the other thread):
Quote
In fact (not to get too far off topic), I realised that I should probably remove the headers/pc files for the compile utilities that are not in the dsl base (textinfo, bison, flex, etc).
Couldn't removing the .pc also possibly have problems for some configure software looking for some bin/libs?  I don't think dev files are split into their own .pc, so there might be some manual tweaking needed?

Posted by Juanito on May 09 2008,06:51
In fact looking in /opt/compile-3.3.5/lib/pkgconfig, there are:
Code Sample
$ ls /opt/compile-3.3.5/lib/pkgconfig
freetype2.pc  glib.pc       gthread.pc    libpng.pc     libpng12.pc
gdk.pc        gmodule.pc    gtk+.pc       libpng10.pc   openssl.pc

- all of which appear to refer to the base dsl libs, so I guess bison, flex, etc did not create any pc files and it's OK to leave what there is in place.

Posted by Jason W on May 09 2008,12:28
Actually libXrender is in the base system, but no dev files of course.  I had this same issue when building Xchat.  It insisted on the .la file. I was building it against xorg72, and at the time I just compiled my own libXrender and installed it in xorg72 to provide the .la and .a file.  That is why I asked earlier about xorg72 including the .a and .la files in the extension.  So I am pretty sure if xorg72 is loaded and the pkgconfig stuff set that the compile error would go away.  And xorg72 did not end up as a dependency with Xchat
Posted by Juanito on May 09 2008,13:37
I'd looked in  /opt/gnu-utils (from an old gnu-utils) and found libXrender so I assumed that was where it came from, but you're right it's also in /KNOPPIX/X11R6/lib

I'd forgotten I'd submitted xorg72-dev.tar.gz - the .a and .la files for xorg72 are there - this doesn't get round not having the dev files for libXrender in the dsl base, but I never figured out where it came from so I couldn't include the dev files in compile-3.3.5

As you say, you could probably get away with compiling against xorg72 - not exactly the "done thing", but it could well work...

Posted by andrewb on May 11 2008,10:15
I've not had a chance to do much with this over the weekend, but at the end of last week I loded up xorg72 & the dev.tar.gz - only problem is the tar.gz couldn't load over xorg72,uci as it is read-only. Once I'v managed to extract xorg72 to a r-w filesystem  I'll let you know how I go.

My reason for trying to recompile gtkam is that I get nothing but segmentation faults with the version in the repository - especially when trying to start downloading images. Someone else rported this recently & it reminded me to get on with attempting a recompilation with the newest version.

Posted by andrewb on May 12 2008,02:05
OK,

I've remounted xorg72.uci as rw, mounted the devs - managed to recompile libXrender so I have the .la files. Got libusb, libexif, libexif-gtk,libgphoto2, & gphoto2,  compiled & installed. Now trying to compile gtkam. the configre script exits ok:

Code Sample


Configuration (gtkam 0.1.15):

 Build
   Source code location:          .
   Compiler:                      gcc

 Features
   Use translations:              yes
   libgphoto2:                    yes
   bonobo support:                no (bonobo-activation, bononoboui libs)
   Gnome support:                 no (gnomeui lib)
   GTKAM_C_IDENTIFIER:            file:$(datadir)/gnome/help/gtkam/C/gtkam.xml
   Gimp support:                  no
   libexif:                       yes
   libexif-gtk:                   yes

You may run "make" and "make install" now.


BUT.... make fails:

Code Sample

gcc -g -O2 -Wall -g -o gtkam gtkam-gtkam-debug.o gtkam-gtkam-exif.o gtkam-gtkam-                                                                                     main.o gtkam-main.o  libgtkam.a -L/usr/local/lib /usr/local/lib/libexif-gtk.so -                                                                                     L/usr/X11R6/lib -L/opt/xorg72/lib /usr/lib/libgtk-x11-2.0.so /usr/lib/libgdk-x11                                                                                     -2.0.so /usr/lib/libatk-1.0.so /usr/lib/libgdk_pixbuf-2.0.so /usr/lib/libpangoca                                                                                     iro-1.0.so /usr/lib/libpangoft2-1.0.so /usr/lib/libpango-1.0.so /usr/lib/libcair                                                                                     o.so /usr/lib/libfontconfig.so /usr/lib/libfreetype.so -lz /usr/lib/libexpat.so                                                                                      -lpng12 /usr/local/lib/libXrender.so -lSM -lICE -lX11 /usr/lib/libgobject-2.0.so                                                                                      /usr/lib/libgmodule-2.0.so /usr/lib/libglib-2.0.so /usr/local/lib/libgphoto2.so                                                                                      -L/opt/build/lib /usr/local/lib/libgphoto2_port.so /opt/compile-3.3.5/lib/liblt                                                                                     dl.so -ldl /usr/local/lib/libexif.so -lm /usr/local/lib/libusb.so  
/usr/lib/libcairo.so: undefined reference to `png_get_IHDR@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_destroy_write_struct@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_write_end@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_tRNS_to_alpha@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_write_fn@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_destroy_read_struct@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_create_read_struct@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_palette_to_rgb@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_read_fn@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_bKGD@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_filler@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_read_image@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_interlace_handling@PNG12_0                                                                                     '
/usr/lib/libcairo.so: undefined reference to `png_get_io_ptr@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_error@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_read_end@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_read_info@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_read_update_info@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_create_write_struct@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_IHDR@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_get_valid@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_packing@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_create_info_struct@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_convert_from_time_t@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_gray_to_rgb@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_write_info@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_write_image@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_read_user_transform_fn@PNG                                                                                     12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_gray_1_2_4_to_8@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_tIME@PNG12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_write_user_transform_fn@PN                                                                                     G12_0'
/usr/lib/libcairo.so: undefined reference to `png_set_strip_16@PNG12_0'
collect2: ld returned 1 exit status
make[2]: *** [gtkam] Error 1
make[2]: Leaving directory `/mnt/hda/gtkam-0.1.15/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/hda/gtkam-0.1.15'
make: *** [all] Error 2
dsl@box:/mnt/hda/gtkam-0.1.15$


I've used the latest version of compile.3.3.5 from the testing area & gtk 2.10.9 + the dev headers for that version as well.

Posted by ^thehatsrule^ on May 12 2008,03:23
You might be using the wrong png version? afaik theres 3(?) different versions if youre using compile-3.3.5?
Posted by Juanito on May 12 2008,03:38
By default compile-3.3.5 is set to use the headers for the most up to date libpng in the base dsl - I'd take a guess that libcairo in gtk 2.10.9 was compiled against a newer version of png but is looking at one of the dsl base versions instead.

Setting PKG_CONFIG_PATH to the location of the libpng pc file in gtk+-2.10.9_devs.dsl might fix the problem - alternatively, you could modify the Makefile(s) by hand to point to libpng in gtk+-2.10.9.dsl and the libpng headers in gtk+-2.10.9_devs.dsl

Posted by andrewb on May 12 2008,04:07
Setting PKG_CONFIG_PATH doesn't seems to change anything. modifying the Makefile is getting out of my depth now (used to know how to understand these files - but have now forgotten!)
Posted by Jason W on May 12 2008,04:30
andrewb -
There should be a libpng.pc or png.pc included with the gtk+-2.1.09 extension and that would be the one to use since it is the one included in the gtk extension and it is the one cairo was built against.  The libpng in gtk+-2.10.9 is version 1.2.8, and the latest version in base DSL is 1.2.5 I believe.  That may be the issue if you are using the pc file from compile-3.3.5 in this case.

Posted by Juanito on May 12 2008,04:50
Quote
modifying the Makefile is getting out of my depth now

- it shouldn't be too big a deal - if Jason's solution above doesn't work (sometimes the pkgconfig setting is ignored), you could try searching the Makefile on "lpng" which should turn up something like "PNG_LIBS = -lpng" and close to it there should be something like "PNG_CFLAGS = ...". You could then alter these to:

PNG_LIBS = -L/path-to-lib/ -lpng
PNG_CFLAGS = -I/path-to-header/

One issue I could see would be that it looks like you are compiling a dsl extension and that your libs will be amongst the base dsl libs in /usr/lib (unless the libpng in question is in /usr/local/lib). This means that there will be several libpng* in the same place and thus ./configure cannot figure out which one to use - you might need to modify the symlink libpng.so to point to the libpng* you want to use...

..or you could compile to /opt and hope to avoid this sort of pain  :)

Edit: BTW (and this is absolutely not a plug), libcairo in cairo-1.2.uci is compiled against the base dsl libpng -if all else fails, you could try compiling against this.

Posted by andrewb on May 12 2008,05:42
No sign of any string 'png' in the Makefile, either in the top level, or in the src directory. (only reference is to a gtkam.png icon file)

I've tried setting PKG_CONFIG_PATH to the pkconfig directory in gtk-+2.10.9 with libpng.pc in it & also creating a symlinkin /usr/local/lib (&/usr/lib)  to the libpng.so in gtk-+2.10.9. Still get the same errors.

Posted by Juanito on May 12 2008,06:46
I'm not at a dsl machine right now, which libpng* are there in gtk-+2.10.9? Are they in /usr/lib or /usr/local/lib?
Posted by andrewb on May 12 2008,07:15
/usr/local/lib

They are:
Code Sample
dsl@box:/opt/gtk+-2.10.9/usr/local/lib$ ls
libpng.so            libpng.so.3.1.2.8    libpng12.so.0
libpng.so.3          libpng12.so          libpng12.so.0.1.2.8



I have added the following to the Makefile in the top level & src directories I am using to compile gtkam from:

Code Sample
PNG_LIBS = -L/usr/local/lib  -lpng
PNG_CFLAGS = -I/usr/local/include


/usr/local/lib has the libpng & libpng12 files in it (I symlinked them to to the ones in /opt/gtk-+2.10.9/usr/local/lib). There also seem to be copies in /usr/lib. I symlinked them the same as above.

Posted by Juanito on May 12 2008,11:06
Quote
PNG_LIBS = -L/usr/local/lib  -lpng
PNG_CFLAGS = -I/usr/local/include

- sorry if I might have mislead you, this was just my guess at what the Makefile might say. If it doesn't say this, then I don't think adding the above would have any effect.

I was concerned that I might be be causing your problems by a mistake in compile-3.3.5, so I tried compiling gtkam to /opt. It seems to compile without problems against cairo-1.2/gtk+-2.10, although I cannot test it as I do not have a webcam, camera, etc handy

Posted by andrewb on May 12 2008,23:23
I can't get gtkam to compile under any conditions - even adding to the makefile. What version are yo compiling & what extensions / libraries do you have loaded when doing so? What version of DSL are you running the compile on?
Posted by Juanito on May 13 2008,04:08
Using dsl-3.4.11, I loaded the cairo-1.2.uci, gtk+-2.10.uci, xorg72.uci & compile-3.3.5.uci extensions - note that you need to be careful that the fontconfig (fc-*) and freetype symlinks in /opt/bin are pointing to cairo-1.2 and not to compile-3.3.5. [I guess this means that I missed these symlinks out out of user.tar.gz in cairo-1.2]

The compilation went something like this:
Code Sample
$ cp -a /opt/compile-3.3.5/include /opt
$ export CPPFLAGS=-I/opt/include
[libusb-0.1.12]
$ ./configure --prefix=/opt/gtkam --enable-shared --disable-static
[make, make install]
$ sudo ln -s /opt/gtkam/bin/* /opt/bin
$ export PKG_CONFIG_PATH=/opt/gtkam/lib/pkgconfig:/opt/cairo-1.2/lib/pkgconfig:/opt/gtk+2.10/lib/pkgconfig:/opt/xorg72/lib/pkgconfig
[libexif-0.6.16]
$ ./configure --prefix=/opt/gtkam --enable-shared --disable-static --disable-docs
[make, make install]
$ sudo ln -s /opt/gtkam/include/libexif/* /opt/gtkam/include
[libexif-gtk-0.3.5]
$ ./configure --prefix=/opt/gtkam --enable-shared --disable-static
[make, make install]
[libgphoto2-2.4.1]
$ ./configure --prefix=/opt/gtkam --enable-shared --disable-static
[make, make install]
[gphoto2-2.4.1]
$ ./configure --prefix=/opt/gtkam --enable-shared --disable-static
[make, make install]
[gtkam-0.1.15]
$ ./configure --prefix=/opt/gtkam --enable-shared --disable-static
Configuration (gtkam 0.1.15):

 Build
   Source code location:          .
   Compiler:                      gcc

 Features
   Use translations:              yes
   libgphoto2:                    yes
   bonobo support:                no (bonobo-activation, bononoboui libs)
   Gnome support:                 no (gnomeui lib)
   GTKAM_C_IDENTIFIER:            file:$(datadir)/gnome/help/gtkam/C/gtkam.xml
   Gimp support:                  no
   libexif:                       yes
   libexif-gtk:                   yes
[make, make install]

- after making a *uci out of /opt/gtkam, I rebooted and loaded cairo-1.2 and gtk+-2.10 but not compile-3.3.5 nor xorg72 and got this error:
Code Sample
$ LD_LIBRARY_PATH=/opt/gtkam/lib /opt/gtkam/bin/gtkam
/opt/gtkam/bin/gtkam: error while loading shared libraries: libltdl.so.3: cannot open shared object file: No such file or directory
[fix]
$ sudo cp /opt/compile-3.3.5/lib/libltdl* /opt/gtkam/lib
[redo *uci]


'hope this helps  :)

Posted by andrewb on May 13 2008,04:52
When I try to compile using the cairo-1.2 extension make fails compiling the libexif-gtk library with the message:

Code Sample
gcc -g -O2 -Wall -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -o .libs/test-libexif-gtk test-libexif-gtk.o  ../libexif-gtk/.libs/libexif-gtk.so -L/opt/gtkam/lib -L/opt/cairo-1.2/lib -L/opt/gtk+-2.10/lib /opt/gtk+-2.10/lib/libgtk-x11-2.0.so /opt/gtk+-2.10/lib/libgdk-x11-2.0.so /opt/gtk+-2.10/lib/libatk-1.0.so /opt/gtk+-2.10/lib/libgdk_pixbuf-2.0.so /opt/gtk+-2.10/lib/libpangocairo-1.0.so /opt/gtk+-2.10/lib/libpango-1.0.so /opt/cairo-1.2/lib/libcairo.so /opt/gtk+-2.10/lib/libgobject-2.0.so /opt/gtk+-2.10/lib/libgmodule-2.0.so -ldl /opt/gtk+-2.10/lib/libglib-2.0.so /opt/gtkam/lib/libexif.so -lm -Wl,--rpath -Wl,/opt/gtkam/lib
/opt/cairo-1.2/lib/libcairo.so: undefined reference to `FT_GlyphSlot_Embolden'
collect2: ld returned 1 exit status
make[2]: *** [test-libexif-gtk] Error 1
make[2]: Leaving directory `/mnt/hdb/libexif-gtk-0.3.5/tests'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/hdb/libexif-gtk-0.3.5'
make: *** [all] Error 2
dsl@box:/mnt/hdb/libexif-gtk-0.3.5$


I had encountered this before your explanation of your compiling method. I have checked this under 3.11 using a base frugal installation and only cairo1.2, gtk+-2.10, xorg72 * compile3.3.5. I redid the symlinks in /opt/bin to point to the fc & freetype files in cairo.

Posted by Juanito on May 13 2008,05:00
Quote
/opt/cairo-1.2/lib/libcairo.so: undefined reference to `FT_GlyphSlot_Embolden'
collect2: ld returned 1 exit status

- I believe this is because libcairo is trying to use the freetype/fontconfig libs in the base dsl. You could try either:

1. Move "/opt/cairo-1.2/lib" above "/usr/lib" in /etc/ld.so.conf and then "sudo ldconfig"

or

2. [Brute Force method] delete the freetype/fontconfig libs in /usr/lib then "sudo ldconfig"

..and then try make again.

BTW, once compiled, the gtkam *uci I made starts up without touching /etc/ld.so.conf or deleting the freetype/fontconfig libs in /usr/lib

Posted by andrewb on May 13 2008,07:40
OK,

Finally got it compiled. Then got the error:

Code Sample
dsl@box:/opt/gtkam/bin$ gtkam
gtkam: relocation error: /opt/gtk+-2.10/lib/libgobject-2.0.so.0: undefined symbol: g_regex_unref

when I ran it. Sorted this by moving /opt/gtk+-2.10/lib above /urs/lib in ld.so.conf & running ldconfig.

Now to try a reboot......

does the same - still need to edit ld.so.conf

Posted by Juanito on May 13 2008,09:26
I had been starting gtkam with "LD_LIBRARY_PATH=/opt/gtkam/lib /opt/gtkam/bin/gtkam" and did not get this error, but you could try "LD_LIBRARY_PATH=/opt/gtkam/lib:/opt/gtk+-2.10/lib /opt/gtkam/bin/gtkam" or put symlinks to /opt/gtk+-2.10/lib/glib2* in /opt/gtkam/lib
Posted by andrewb on May 22 2008,06:05
Juanito - thanks for all the help. An update version of gtkam should be in testing soon - along with gnokii.
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.