OpenWrt Forum Archive

Topic: ld error when trying to compile with SDL, library files not found

The content of this topic has been archived on 23 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all,

I've just setup a cross compiler toolchain so i can compile programs for a Ben NanoNote running openwrt. The wiki for the NanoNote has this page with a basic c program and Makefile to test the compiler works: http://en.qi-hardware.com/wiki/Compilin … e_NanoNote

I've copied and pasted the code from here changing the directories to reflect my setup but when i try and run Make, or the gcc command make generates, I get an error from ld stating it can't find some of the libraries required by SDL.

Heres the output i get from make:

marco@ServerLOL:/media/HDD/Apps/NanoNote/Apps/Test$ make V=99
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-uclibc-gcc main.o -o hello-sdl -W1,-rpath-link=/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib -lSDL -L/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib
mipsel-openwrt-linux-uclibc-gcc: warning: environment variable 'STAGING_DIR' not defined
mipsel-openwrt-linux-uclibc-gcc: warning: environment variable 'STAGING_DIR' not defined
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/lib/gcc/mipsel-openwrt-linux-uclibc/4.6.4/../../../../mipsel-openwrt-linux-uclibc/bin/ld: warning: libdirectfb-1.4.so.0, needed by /media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so, not found (try using -rpath or -rpath-link)
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/lib/gcc/mipsel-openwrt-linux-uclibc/4.6.4/../../../../mipsel-openwrt-linux-uclibc/bin/ld: warning: libfusion-1.4.so.0, needed by /media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so, not found (try using -rpath or -rpath-link)
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.6-linaro_uClibc-0.9.33.2/lib/gcc/mipsel-openwrt-linux-uclibc/4.6.4/../../../../mipsel-openwrt-linux-uclibc/bin/ld: warning: libdirect-1.4.so.0, needed by /media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so, not found (try using -rpath or -rpath-link)
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so: undefined reference to `DirectFBCreate'
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so: undefined reference to `DirectFBErrorString'
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so: undefined reference to `DirectFBError'
/media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so: undefined reference to `DirectFBInit'
collect2: ld returned 1 exit status
make: *** [hello-sdl] Error 1

I believe the error about STAGING_DIR not being defined is irelevant, it's set in the makefile and i've tried setting it to the same value as an environment variable but this made no diffirence to the SDL errors, it just removed the warnings about STAGING_DIR

The files it says are missing can all be found in the directory included by -rpath-link and -L:

marco@ServerLOL:/media/HDD/Apps/NanoNote/Apps/Test$ ls -l /media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib
total 9528
drwxrwxr-x 6 marco marco    4096 May 16 13:07 directfb-1.4-0
-rwxrwxr-x 1 marco marco 1715892 May 16 13:09 libasound.a
...
lrwxrwxrwx 1 marco marco      22 May 16 13:07 libdirect-1.4.so.0 -> libdirect-1.4.so.0.2.0
-rwxrwxr-x 1 marco marco   77721 May 16 13:07 libdirect-1.4.so.0.2.0
lrwxrwxrwx 1 marco marco      24 May 16 13:07 libdirectfb-1.4.so.0 -> libdirectfb-1.4.so.0.2.0
-rwxrwxr-x 1 marco marco  601334 May 16 13:07 libdirectfb-1.4.so.0.2.0
...
lrwxrwxrwx 1 marco marco      22 May 16 13:07 libfusion-1.4.so.0 -> libfusion-1.4.so.0.2.0
-rwxrwxr-x 1 marco marco   43125 May 16 13:07 libfusion-1.4.so.0.2.0
...
drwxrwxr-x 2 marco marco    4096 May 16 12:23 lua
drwxrwxr-x 2 marco marco    4096 May 16 13:10 pkgconfig

the SDL libraries is in the same folder and I assume its found that ok as the errors all seem to be about SDL's own requirements.

Can anyone give me any help with these errors?

0.9.33.2/lib/gcc/mipsel-openwrt-linux-uclibc/4.6.4/../../../../mipsel-openwrt-linux-uclibc/bin/ld: warning: libdirectfb-1.4.so.0, needed by /media/HDD/Apps/NanoNote/OS/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.33.2/usr/lib/libSDL.so, not found

I'm not sure, but do you cross-compile the libSDL also?

Hi Mapisto,

thanks for the reply but my linux system failed and had to be rebuilt recently so i've lost the setup i had. still restoring things so it'll be a while before i look into this again. i've also taken this oppurtunity to switch from Ubuntu to plain Debian and, from my initial impresions of Debian, I wouldn't be suprised if going through the same setup just works this time.

If it's worth anything i'm pretty sure libSDL was cross compiled when it was setup. I installed it like a package of openwrt, like in the root directory of where openwrt was compiled you can type something like "make package/libSDL/compile" to compile a particular package. not sure if libSDL was part of openwrt or something specific for the NanoNote but as far as i could tell it compiled fine using the cross compiler toolchain, all the library files appeared in the right directory afterwords.

I'd apreciate it if you have any ideas why that might be an issue in case i am doing something stupid but it's no big deal just now.

The discussion might have continued from here.