terryky / tflite_gles_app

GPU accelerated deep learning inference applications for RaspberryPi / JetsonNano / Linux PC using TensorflowLite GPUDelegate / TensorRT
MIT License
488 stars 130 forks source link

Linking error in Raspi-3 #9

Closed satyajitghana closed 3 years ago

satyajitghana commented 3 years ago

I was trying to build the examples in my raspberry pi 3, but i got this error:

/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform2i'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform1f'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glMemoryBarrier'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform1ui'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glGetBufferParameteri64v'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glCopyBufferSubData'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glFenceSync'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glTexSubImage3D'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform4f'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glTexStorage2D'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform4ui'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glUnmapBuffer'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform4fv'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glBindBufferRange'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glBindImageTexture'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glClientWaitSync'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glGetProgramBinary'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform1i'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glGetStringi'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glMapBufferRange'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform4i'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform2f'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glGetSynciv'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramUniform2iv'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glProgramBinary'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glDeleteSync'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glTexStorage3D'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glDispatchCompute'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glGetIntegeri_v'
/usr/bin/ld: /home/pi/lib/libtensorflowlite_gpu_delegate.so: undefined reference to `glDrawBuffers'

I can confirm that i've installed all the required libraries, followed the guide from here: https://github.com/terryky/tflite_gles_app#23-build-for-armv7l-linux-raspberry-pi

also installed: sudo apt install libgles2-mesa-dev libegl1-mesa-dev xorg-dev mesa-common-dev

terryky commented 3 years ago

Are you trying to use the GPUDelegate ? Unfortunately, GPUDelegate requires OpenGLES 3.1 or higher, but RPi3 doesn't support it.

Could you retry without GPUDelegate:

make -j4 TARGET_ENV=raspi
satyajitghana commented 3 years ago

Are you trying to use the GPUDelegate ? Unfortunately, GPUDelegate requires OpenGLES 3.1 or higher, but RPi3 doesn't support it.

Could you retry without GPUDelegate:

make -j4 TARGET_ENV=raspi

yeah I tried to compile "without" GPUDelegate, but it didn't work.

make -j4 TARGET_ENV=raspi is the command that gave me linker errors at the end.

something to note: if I use TARGET_ENV=raspi4 then I am able to successfully link everything and I get the target executable, but the application doesn't work, black screen, with errors that JPEG is not supported for raspi camera.

terryky commented 3 years ago

I'm not sure your RPi3's OpenGLES environment but if your RPi3 doesn't have OpenGL driver with full KMS, please enable it.

please refer: https://raspberrypi.stackexchange.com/questions/75071/running-modern-opengl-on-raspberry-pi

satyajitghana commented 3 years ago

I've enabled full KMS, not sure if it was disabled before. i followed this: https://raspberrypi.stackexchange.com/questions/75071/running-modern-opengl-on-raspberry-pi , glxgears works.

with make -j4 TARGET_ENV=raspi i still get the linking error.

with make -j4 TARGET_ENV=raspi4 the linking error is gone but i get: ERR: camera_capture.c(87): pixformat(JPEG) is not supported

terryky commented 3 years ago

hmm, could you try to launch the app with -x option like below ?

$ make -j4 TARGET_ENV=raspi4
$ ./gl2handpose -x
satyajitghana commented 3 years ago

yep, ./gl2handpose -x works ! i tried other examples as well, they work too !

so this is to do something with the camera ?

terryky commented 3 years ago

OK. -x option just disables the camera.

next, could you try blow?

$ sudo apt-get install v4l-utils
$ v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=YUYV --set-parm=30
$ ./gl2handpose 
satyajitghana commented 3 years ago

yup, that's working now !

terryky commented 3 years ago

great. Does the problem solved ?

Just in case, please tell me which libraries does your app link to. Could you copy and paste the result of below command ?

$ ldd gl2handpose
satyajitghana commented 3 years ago

yes, problem is solved

pi@raspberrypi:~/work/tflite_gles_app/gl2handpose $ ldd gl2handpose
    linux-vdso.so.1 (0x7ed57000)
    /usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0x76f9b000)
    libEGL.so.1 => /usr/lib/arm-linux-gnueabihf/libEGL.so.1 (0x76f63000)
    libGLESv2.so.2 => /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2 (0x76f44000)
    libX11.so.6 => /usr/lib/arm-linux-gnueabihf/libX11.so.6 (0x76e22000)
    libdrm.so.2 => /usr/lib/arm-linux-gnueabihf/libdrm.so.2 (0x76e03000)
    libtensorflowlite.so => /home/pi/lib/libtensorflowlite.so (0x76b30000)
    libtensorflowlite_gpu_delegate.so => /home/pi/lib/libtensorflowlite_gpu_delegate.so (0x767c3000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x7667c000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x765fa000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x765cd000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x765a3000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76455000)
    libGLdispatch.so.0 => /usr/lib/arm-linux-gnueabihf/libGLdispatch.so.0 (0x763d6000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x763c3000)
    /lib/ld-linux-armhf.so.3 (0x76fb0000)
    libxcb.so.1 => /usr/lib/arm-linux-gnueabihf/libxcb.so.1 (0x76394000)
    librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x7637d000)
    libXau.so.6 => /usr/lib/arm-linux-gnueabihf/libXau.so.6 (0x7636a000)
    libXdmcp.so.6 => /usr/lib/arm-linux-gnueabihf/libXdmcp.so.6 (0x76355000)
    libbsd.so.0 => /usr/lib/arm-linux-gnueabihf/libbsd.so.0 (0x7632d000)
terryky commented 3 years ago

Thanks. it looks fine.