Imagination PowerVR SDK Blog

[SOLVED] Running ReleaseRaw and cross-compiling for X11


#1

Hi,

I have difficulties cross-compiling SDK examples for TI OMAP5 running Ubuntu Precise (12.04LTS). Toolchain and SDK are set up and work just fine.



I can generate raw executable examples but don’t know how to run them. Can you provide some information on that. (In this case I am running program from console without X11.)

When I try to cross-compile for X11 environment, linker fails because of missing X11 libs while native compile for x86_64 and X11 works fine and program runs.


#2

Hi,



Before running null window system (raw) application, you need to ensure X11 has been stopped (if it was running). Once X11 has been killed, you should be able to launch the application from the console.



If you want to instead build an X11 version of our Examples, you need to set an X11ROOT environment variable that points to your target’s X11 libraries & add X11BUILD=1 to your command-line arguments for make. Our SDK User Guide also details these steps.



Let us know if you hit any other issues.



Thanks,

Joe


#3

When building X11, I provide both X11BUILD and X11ROOT so everything is supposed to run.

Compiler passes but I cannot link with X11 libs. This is what I get.


/home/doking-dev/gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux/bin/arm-linux-gnueabihf-g++ -o ../Linux_armv7/ReleaseX11/OGLES2Water ../Linux_armv7/ReleaseX11/OGLES2Water.o ../Linux_armv7/ReleaseX11/NewNormalMap.o ../Linux_armv7/ReleaseX11/Mountain.o ../Linux_armv7/ReleaseX11/wood.o ../Linux_armv7/ReleaseX11/sail.o ../Linux_armv7/ReleaseX11/MountainFloor.o ../Linux_armv7/ReleaseX11/FragShader.o ../Linux_armv7/ReleaseX11/VertShader.o ../Linux_armv7/ReleaseX11/SkyboxFShader.o ../Linux_armv7/ReleaseX11/SkyboxVShader.o ../Linux_armv7/ReleaseX11/ModelFShader.o ../Linux_armv7/ReleaseX11/ModelVShader.o ../Linux_armv7/ReleaseX11/Tex2DFShader.o ../Linux_armv7/ReleaseX11/Tex2DVShader.o ../Linux_armv7/ReleaseX11/PlaneTexFShader.o ../Linux_armv7/ReleaseX11/PlaneTexVShader.o ../Linux_armv7/ReleaseX11/Scene.o ../Linux_armv7/ReleaseX11/PVRShell.o ../Linux_armv7/ReleaseX11/PVRShellAPI.o ../Linux_armv7/ReleaseX11/PVRShellOS.o  -L/usr/include/X11//lib -Wl,--rpath-link,/usr/include/X11//lib -lX11 -lXau -lGLESv2 -lEGL -L/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Tools/OGLES2/Build/LinuxGeneric/../Linux_armv7/ReleaseX11 -logles2tools -L"/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Linux/armv7/Lib" -Wl,--rpath-link,"/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Linux/armv7/Lib"<br />
/home/doking-dev/gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lX11<br />
/home/doking-dev/gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lXau<br />
collect2: error: ld returned 1 exit status<br />
make: *** [../Linux_armv7/ReleaseX11/OGLES2Water] Error 1

#4

You should be linking to your target’s X11 libs. Have you accidentally linked to your host machine’s libs while cross-compiling?



Thanks,

Joe


#5

Yes, I have.

So I have to copy libs from my host system and use their path as argument of X11ROOT? Cross-compiling X11 doesn’t look appealing to me.


#6

If you want to cross-compile for X11, you either have to either copy the libraries from your target to a directory on your host, or mount the target’s X11 directory so you can link against it remotely.



Thanks,

Joe


#7

I have tried both options and both have failed with the same result as before -lX11 and -lXau not found.

I am calling make like this make PLATFORM=Linux_armv7 X11BUILD=1 X11ROOT=/media/rootfs/usr/include/X11

Error message is same as few posts before.


#8

Hi,



The X11ROOT variable is designed to point at the location that has the include and lib folders that contain your X11 libs and headers. Based on what you’ve set your X11ROOT to, could you try

X11ROOT=/media/rootfs/usr



If that doesn’t work, could you let us know where your libX11.so is located on your system.



Cheers,



Scott


#9

libX11.so is in /media/rootfs/usr/lib/arm-linux-gnueabihf/ libXau is in same directory as well.

I have tried make with /media/rootfs/usr. Again with the same error.


#10

Just to avoid problems, after each unsuccessful make I do make clean for that build.

Also, what might interest you is contains of .bashrc which is

export PATH="/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1:$PATH"

export TOOLCHAIN="/home/doking-dev/gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux"





$CROSS_COMPILE is not set and I am using latest Linaro toolchain for armhf


#11
libX11.so is in
/media/rootfs/usr/lib/arm-linux-gnueabihf/
libXau is in same directory as well.
I have tried make with /media/rootfs/usr. Again with the same error.

Ok, looks like you'll need to modify the ws.mak in /Builds/Linux/armv7 so all the references to
$(X11ROOT)/lib
are changed to
$(X11ROOT)/lib/arm-linux-gnueabihf
Hopefully that'll get things linking.

#12

OK. We have that working. BUT agony is not over yet :slight_smile:

Linking now stops with this error:



/home/doking-dev/gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux/bin/…/lib/gcc/arm-linux-gnueabihf/4.8.2/…/…/…/…/arm-linux-gnueabihf/bin/ld: cannot find /lib/arm-linux-gnueabihf/libc.so.6

/home/doking-dev/gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux/bin/…/lib/gcc/arm-linux-gnueabihf/4.8.2/…/…/…/…/arm-linux-gnueabihf/bin/ld: cannot find /usr/lib/arm-linux-gnueabihf/libc_nonshared.a

/home/doking-dev/gcc-linaro-arm-linux-gnueabihf-4.8-2013.06_linux/bin/…/lib/gcc/arm-linux-gnueabihf/4.8.2/…/…/…/…/arm-linux-gnueabihf/bin/ld: cannot find /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3

collect2: error: ld returned 1 exit status

make: *** […/Linux_armv7/ReleaseX11/OGLES2Water] Error 1


#13

My idea why make fails is because cross-compiler supports multiarch. libc.so.6 and other files might have been moved to different location and therefore make fails to locate and use them.

Any solution for that?


#14

SOLVED



Had to copy contents from /libc/lib to system /lib and /libc/usr/lib to system /usr/lib. Make searches for those files inside of the system libraries instead of the toolchain libs. Maybe this can be fixed more easily by using LD_LIBRARY_PATH?



Thank you guys, helped me a lot.