Cross compiling: cannot find -lx11

2 posts
by UnknownFury » Tue Nov 06, 2012 9:21 pm

I'm new to cross compiling (and the raspberry pi). I have managed to get basic applications compiling using raspberry pi tools ( This is all compiling and working fine. Now I'm starting to use the CImg library which uses X11. I'm compiling that natively in linux on my PC using:

Code: Select all
g++ -o native-cimg-test "cimg_test.cpp" -O2 -L/usr/X11R6/lib -lm -lpthread -lX11

Which works great. However when I try to compile it for pi using arm-bcm2708-linux-gnueabi-g++ with those same flags, I get the error:

Code: Select all
/home/will/pi/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/../lib/gcc/arm-bcm2708-linux-gnueabi/4.7.1/../../../../arm-bcm2708-linux-gnueabi/bin/ld: cannot find -lx11
collect2: error: ld returned 1 exit status
make: *** [cimg-pi] Error 1

I don't really know what all those flags do so trying to find the problem is proving difficult. I assume I need libx11.a/so for the raspberry pi? Any pointers would be great
Posts: 1
Joined: Tue Nov 06, 2012 9:14 pm
by xvzf » Thu Nov 08, 2012 5:51 pm
I solved this Problem using the pi it self.
Code: Select all
sudo apt-get install libx11-dev

on your Pi and copy /usr/lib/* to your toolchains library path (usually ./sysroot/lib/) and /usr/include/* to the include directory of your toolchain.

I hope this helps you

Posts: 8
Joined: Sun Nov 04, 2012 11:12 am