otto_zh
Posts: 6
Joined: Wed Feb 07, 2018 12:57 pm

Crosscompiled EGL wrong linked addresses

Wed Feb 07, 2018 1:09 pm

Dear

Im new to raspberry pi but not in embedded c programming.

I wrote a simple programm who draw a triangle directly on EGL.

When I compile and link it on the raspberry pi it runs correctly.
When I cross compile it from a Windows 10 with Linaro gcc toolchain it dosnt run: segmentation fault.
gcc -c triangle.c -I/opt/vc/include
gcc -o triangle -L/opt/vc/lib -lEGL -lGLESv2 -lbcm_host -lvcos -lvchiq_arm -lpthread -lrt triangle.o

ldd EGL_Simple/triangle
linux-vdso.so.1 (0x7eef5000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f58000)
libEGL.so => /opt/vc/lib/libEGL.so (0x76f1f000)
libGLESv2.so => /opt/vc/lib/libGLESv2.so (0x76efa000)
libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x76ed3000)
libvcos.so => /opt/vc/lib/libvcos.so (0x76eb9000)
libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x76ea3000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e7a000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76e63000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76d24000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76ca5000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c92000)
/lib/ld-linux-armhf.so.3 (0x76f6e000)

[email protected]:~ $ ldd projects/EGL_Simple/EGL_Simple
linux-vdso.so.1 (0x7edd0000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76eb8000)
libEGL.so => /opt/vc/lib/libEGL.so (0x76e7f000)
libGLESv2.so => /opt/vc/lib/libGLESv2.so (0x76e5a000)
libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x76e33000)
libvcos.so => /opt/vc/lib/libvcos.so (0x76e19000)
libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x76e03000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76dda000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76dc3000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c84000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76c05000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76bf2000)
/lib/ld-linux-armhf.so.3 (0x76ee1000)


What goes wrong with the cross toolchain? Any ideas?

Thanks for help

User avatar
topguy
Posts: 4987
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Crosscompiled EGL wrong linked addresses

Thu Feb 08, 2018 11:48 am

Is the crosscompiler compile and link commands identical to the native ones ?

Are you linking with the exact same version of libraries ?

otto_zh
Posts: 6
Joined: Wed Feb 07, 2018 12:57 pm

Re: Crosscompiled EGL wrong linked addresses

Fri Feb 09, 2018 11:24 am

Dear

Ive download the master version of the precompiled firmware libraries from https://github.com/raspberrypi.
The version are the same 4.6.79-v7.
A simple helloworld is compiling and linking correctly. It seems there are a difference on the libraries from github.
Do you have any tipp for me what I can do?

otto_zh
Posts: 6
Joined: Wed Feb 07, 2018 12:57 pm

[SOLVED] Crosscompiled EGL wrong linked addresses

Fri Feb 09, 2018 11:37 am

Hi

Ive found the solution. I dont list all used libraries in the linker command line

Return to “C/C++”