fltkhs
fltkhs copied to clipboard
Linking issues under linux
I wanted to give fltkhs a try but I cannot seem to get it installed in my system (x86_64 gentoo linux). While compling the library itself seems to succeed, the executables that use it cannot be compiled with the process failing at the linking stage. This includes executalbes fltkhs-fluidtohs, fltkhs-buttons, and fltkhs-hello-world.
For example, I tried to run the following: mkdir /tmp/fltkhs && cd /tmp/fltkhs && cabal sandbox init && cabal install c2hs && cabal install fltkhs. Here's the output of the last command: https://gist.github.com/redneb/ab5130e06f950109f69b.
Maybe a extra-libraries: is missing from the cabal file.
From the output it looks like you might have the wrong version of fltk installed. What is the output of fltk-config --version? If it is 1.3.3 can you post the output of ls <your-lib-directory>/libfltk*?
The fltk version is 1.3.3, as your instructions specify.
Gentoo installs the .so & .a files of fltk in a dedicated directory:
# ls -lh /usr/lib/fltk
total 4.9M
-rwxr-xr-x 1 root root 3.1M Mar 4 23:03 libfltk.a
-rwxr-xr-x 1 root root 5.8K Mar 4 23:03 libfltk_cairo.a
lrwxrwxrwx 1 root root 20 Mar 4 23:03 libfltk_cairo.so -> libfltk_cairo.so.1.3
-rwxr-xr-x 1 root root 9.8K Mar 4 23:03 libfltk_cairo.so.1.3
-rwxr-xr-x 1 root root 60K Mar 4 23:03 libfltk_forms.a
lrwxrwxrwx 1 root root 20 Mar 4 23:03 libfltk_forms.so -> libfltk_forms.so.1.3
-rwxr-xr-x 1 root root 27K Mar 4 23:03 libfltk_forms.so.1.3
-rwxr-xr-x 1 root root 359K Mar 4 23:03 libfltk_gl.a
lrwxrwxrwx 1 root root 17 Mar 4 23:03 libfltk_gl.so -> libfltk_gl.so.1.3
-rwxr-xr-x 1 root root 114K Mar 4 23:03 libfltk_gl.so.1.3
-rwxr-xr-x 1 root root 110K Mar 4 23:03 libfltk_images.a
lrwxrwxrwx 1 root root 21 Mar 4 23:03 libfltk_images.so -> libfltk_images.so.1.3
-rwxr-xr-x 1 root root 56K Mar 4 23:03 libfltk_images.so.1.3
lrwxrwxrwx 1 root root 14 Mar 4 23:03 libfltk.so -> libfltk.so.1.3
-rwxr-xr-x 1 root root 1.1M Mar 4 23:03 libfltk.so.1.3
The location of the libraries seems to be the problem. If I manually copy them to /usr/lib then everything works fine.
What is the output of fltk-config --ldstaticflags --use-gl --use-images --use-glut? That is the command fltkhs uses to determine the location of the libraries.
$ fltk-config --ldstaticflags --use-gl --use-images --use-glut
/usr/lib64/fltk/libfltk_images.a -lpng -lz -ljpeg /usr/lib64/fltk/libfltk_gl.a -lGLU -lGL /usr/lib64/fltk/libfltk.a -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11
so it reports the correct paths (i.e. in /usr/lib/fltk).
Yes, I think I see the problem. This is a bug. When building it expects fltk_gl etc. to be in a place that can be found using AC_CHECK_LIB but this doesn't make much sense when fltk-config already has that information. I'll fix it. Thanks for the report!
I'm seeing this in x86_64 Arch Linux, too, when trying to compile fltkhs as a project dependency using stack. Tons of output complaining about undefined references from the cpp files.
$ fltk-config --version
1.3.3
$ ls /usr/lib/libfltk*
/usr/lib/libfltk_forms.so
/usr/lib/libfltk_forms.so.1.3
/usr/lib/libfltk_gl.s0
/usr/lib/libfltk_gl.so.1.3
/usr/lib/libfltk_images.so
/usr/lib/libfltk_images.so.1.3
/usr/lib/libfltk.so
/usr/lib/libfltk.so.1.3
$ fltk-config --ldstaticflags --use-gl --use-images --use-glut
-Wl,-O1,--sort-common,--as-needed,-z,relro
:(
This is happening because the Arch package isn't installing the statically linked versions of those libs which are required by fltkhs. That's why the installation instructions suggest building from source (https://github.com/deech/fltkhs#linux-and-bsd). I just did that on Arch and fltkhs worked.
@redneb, I fixed your issue sometime ago. Would you mind reviewing and closing? @mrak, did that work for you?
Nope, unfortunately I still cannot compile the latest fltkhs from git in my system because of linking problems.
@deech after changing !staticlibs to staticlibs in /etc/makepkg.conf it all compiles correctly :) Thanks for pointing out the static linking requirement.