GTK, can't find libraries

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
Westbeam
Posts: 239
Joined: Dec 22, 2009 9:24
Contact:

GTK, can't find libraries

Post by Westbeam »

Hey :)

I wanted to test a few GTK-code examples, but it doesn't find the libraries while compiling:
Terminal wrote:ld: cannot find -lgtk-x11-2.0
ld: cannot find -lgdk-x11-2.0
ld: cannot find -lgio-2.0
ld: cannot find -lgobject-2.0
ld: cannot find -lglib-2.0
ld: cannot find -lgmodule-2.0
ld: cannot find -lcairo
ld: cannot find -lpango-1.0
ld: cannot find -lgdk_pixbuf-2.0
ld: cannot find -lpangocairo-1.0
ld: cannot find -latk-1.0
But the libraries are there. I can find a "libgtk-x11-2.0.so" in my "/usr/lib/x86_64-linux-gnu" and "/usr/lib". I've reinstalled the libgtk-2.0-dev, but it doesn't help. :(
Any ideas?
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: GTK, can't find libraries

Post by dkl »

Does the FreeBASIC bitness match the libraries (both 32bit or both 64bit)?
Do you have gcc installed (fbc uses gcc -print-file-name=... to find the system library directory)?

It could be useful to take a look at fbc -v output too, especially the linker command.
Westbeam
Posts: 239
Joined: Dec 22, 2009 9:24
Contact:

Re: GTK, can't find libraries

Post by Westbeam »

Of course i have gcc installed, I couldn't compile any code without it. :D

I've tried it with GTK3 too. Here is the fbc -w all -v Output:
http://pastebin.com/rdLRQRik

I tried it with 32bit fbc(0.90)/libraries and with 64bit fbc(1.0)/libraries
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: GTK, can't find libraries

Post by dkl »

Hmm, I forgot, it looks like fbc only asks gcc for gcc's private libdir. In other words, it's interesting that there is no -L option for /usr/lib or /usr/lib/i386-linux-gnu, but that's the way fbc currently works. We rely on ld to know the main lib dir itself.

But the first question should be: where are the 32bit GTK libraries installed on this 64bit system? /usr/lib, /usr/lib32, /usr/lib/i386-linux-gnu?

If the 32bit libraries exist, then the question is why doesn't ld find them. What search dirs does ld have built-in, for "cross-compiling" to 32bit?
ld -m elf_i386 --verbose | grep SEARCH_DIR
If the above doesn't help, we can still check directly where ld will search:
fbc ... -Wl --verbose
Westbeam
Posts: 239
Joined: Dec 22, 2009 9:24
Contact:

Re: GTK, can't find libraries

Post by Westbeam »

32bit-libraries are in "/usr/lib/i386-linux-gnu", also the ones I need.
ld -m elf_i386 --verbose | grep SEARCH_DIR wrote:SEARCH_DIR("/usr/i386-linux-gnu/lib32"); SEARCH_DIR("/usr/x86_64-linux-gnu/lib32"); SEARCH_DIR("=/usr/local/lib/i386-linux-gnu"); SEARCH_DIR("=/usr/local/lib32"); SEARCH_DIR("=/lib/i386-linux-gnu"); SEARCH_DIR("=/lib32"); SEARCH_DIR("=/usr/lib/i386-linux-gnu"); SEARCH_DIR("=/usr/lib32"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
German fbc ... -Wl --verbose wrote:...
Der Versuch, /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so zu öffnen, ist fehlgeschlagen
...
"Opening /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so has failed"
ls /usr/lib/i386-linux-gnu wrote:...
]libgtk2.0-0
libgtk-x11-2.0.so.0
libgtk-x11-2.0.so.0.2400.20
...
But why? I think it's my fault. I feel I can see the problem right in front of my eyes, but can't find it :(
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: GTK, can't find libraries

Post by dkl »

Maybe the -dev package is not installed?

Code: Select all

/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so    (missing? check -dev package)
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0  (installed by normal package)
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.20 (ditto)
Westbeam
Posts: 239
Joined: Dec 22, 2009 9:24
Contact:

Re: GTK, can't find libraries

Post by Westbeam »

It is installed.

EDIT: Wait. Does it find .so.0 libs? What does the -0 mean?
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: GTK, can't find libraries

Post by dkl »

The linker only searches for the normal libfoo.so version, without the version number suffix.

For example:
1. linker opens libfoo.so
2. libfoo.so symlinks to libfoo.so.0
3. libfoo.so.0 symlinks to libfoo.so.0.123
4. libfoo.so.0.123 is the real .so (not a symlink) that will be used by the program.

Typically, the libfoo.so.0 stuff is installed by the libfoo package, and the libfoo.so is installed by the libfoo-dev package.
Westbeam
Posts: 239
Joined: Dec 22, 2009 9:24
Contact:

Re: GTK, can't find libraries

Post by Westbeam »

Oh allright, when i create a link to the .so.0 it works. Weird stuff. Thank you dkl :)
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: GTK, can't find libraries

Post by dkl »

It's weird... in Ubuntu 14.10 amd64, the libgtk2.0-dev:i386 package should provide these symlinks, but installing it doesn't work (the package's multiarch support seems to be incomplete/broken).
https://bugs.launchpad.net/ubuntu/+sour ... ug/1317116
Post Reply