fprime-community / fprime-system-reference

A full-system reference for F´ projects.
Apache License 2.0
23 stars 16 forks source link

Building libcamera for Raspberry Pi Zero #58

Open ethancheez opened 1 year ago

ethancheez commented 1 year ago

@jwest115 Have you tested building libcamera for a Raspberry Pi Zero? Where did you get the cross compiler for the Raspberry Pi you used?

Building using a Rpi Zero cross-compiler produces these errors:

/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `dlopen@GLIBC_2.34'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `fstat64@GLIBC_2.33'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `dlerror@GLIBC_2.34'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `stat64@GLIBC_2.33'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera-base.so: undefined reference to `pthread_cond_clockwait@GLIBC_2.34'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera-base.so: undefined reference to `pthread_mutex_trylock@GLIBC_2.34'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `__libc_single_threaded@GLIBC_2.32'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `dlclose@GLIBC_2.34'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `dladdr@GLIBC_2.34'
/opt/cross-pi-gcc-10.3.0-0/bin/../lib/gcc/arm-linux-gnueabihf/10.3.1/../../../../arm-linux-gnueabihf/bin/ld: ../../lib/raspberrypi/libcamera/build/lib/libcamera.so: undefined reference to `dlsym@GLIBC_2.34'
collect2: error: ld returned 1 exit status
jwest115 commented 1 year ago

@ethancheez I haven't tried building libcamera for a raspberry pi zero. As for the cross compilers I used, I got them from https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads

ethancheez commented 1 year ago

For the libcamera-aarch32.txt file, do these have to be to the path of the cross compiler? Or is libcamera built using the native compilers?

[binaries]
c = 'arm-linux-gnueabihf-gcc'
cpp = 'arm-linux-gnueabihf-g++'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'

Also, if we are using an x86 machine, does the arm have to be changed to x86_64?

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'arm'
endian = 'little'
jwest115 commented 1 year ago

The libcamera-aarch32.txt has the path for the cross compilers. There's some info at https://github.com/raspberrypi/libcamera for building libcamera with native compilers. As for the second question - yes, I believe you would need to change the cpu and cpu_family entries to be x86_64. There's a table in the meson build docs with the options you can use: https://mesonbuild.com/Reference-tables.html#cpu-families