I am working on a project with the Raspberry Pi Zero and since I don't have a monitor to connect the Pi and don't want to use vi through ssh I thouhgt that cross compiling would be a decent solution. I am trying to do it in a Windows machine with WSL since almost all the guides I found use Linux.
For my project I need to use the bcm2835 library for managing the GPIOs of the Pi.
I found this guide which tells me how to build a library for cross compilation: https://medium.com/@au42/the-useful-raspberrypi-cross-compile-guide-ea56054de187 When I run cmake to build the shared library I have this out put.
mariano@MSI:~/raspberrypi/bcm2835-1.68/src$ cmake . - DCMAKE_TOOLCHAIN_FILE=/home/mariano/raspberrypi/pi.cmake
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /home/mariano/raspberrypi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /home/mariano/raspberrypi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/mariano/raspberrypi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-- Check for working CXX compiler: /home/mariano/raspberrypi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mariano/raspberrypi/bcm2835-1.68/src
After that I run make an got this output:
mariano@MSI:~/raspberrypi/bcm2835-1.68/src$ make
Scanning dependencies of target bcm2528
[ 33%] Building C object CMakeFiles/bcm2528.dir/bcm2835.c.o
/home/mariano/raspberrypi/bcm2835-1.68/src/bcm2835.c: In function 'bcm2835_delay':
/home/mariano/raspberrypi/bcm2835-1.68/src/bcm2835.c:531:5: warning: implicit declaration of function 'nanosleep' [-Wimplicit-function-declaration]
nanosleep(&sleeper, NULL);
^
/home/mariano/raspberrypi/bcm2835-1.68/src/bcm2835.c: In function 'malloc_aligned':
/home/mariano/raspberrypi/bcm2835-1.68/src/bcm2835.c:1754:5: warning: implicit declaration of function 'posix_memalign' [-Wimplicit-function-declaration]
errno = posix_memalign(&mem, BCM2835_PAGE_SIZE, size);
^
[ 66%] Building C object CMakeFiles/bcm2528.dir/test.c.o
In file included from /home/mariano/raspberrypi/bcm2835-1.68/src/test.c:10:0:
/home/mariano/raspberrypi/bcm2835-1.68/src/bcm2835.h:692:8: error: unknown type name 'off_t'
extern off_t bcm2835_peripherals_base;
^
make[2]: *** [CMakeFiles/bcm2528.dir/build.make:76: CMakeFiles/bcm2528.dir/test.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/bcm2528.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Checking the output of the cmake command found these lines
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
I googled it and tried a few solutions but they didn't work.
Is there something I am doing wrong? Also, if you have another method to cross compile tell me, I choose this one because it shows how to use other libraries other that ones that come in Raspbian.
Any help would be appreciated.