How do you cross compile C code for controlling the Raspberry Pi camera on an x86 platform?
I'm trying to create a unittest for compiling and testing the code on a generic x86 continuous integration server (but obviously not connecting to the camera) but I get an error for a missing vcos library:
/home/travis/catkin_ws/src/raspicam_node/src/RaspiCamControl.cpp:32:33: fatal error: interface/vcos/vcos.h: No such file or directory
#include "interface/vcos/vcos.h"
^
compilation terminated.
/home/travis/catkin_ws/src/raspicam_node/src/RaspiCLI.cpp:46:33: fatal error: interface/vcos/vcos.h: No such file or directory
#include "interface/vcos/vcos.h"
^
As far as I can see, this library is only available in the repos for the Raspiberry Pi, and have no x86 candidates in the standard Ubuntu repos. How do I fix this?
Edit: I managed to fix all the include errors by manually installing the Raspberry Pi firmware headers to my /opt/vc.
It now seems to compile my code fine, but it's failing to link it to some shared objects:
####
#### Running command: "make -j4 -l4" in "/tmp/raspicam_node_test/catkin_ws/build"
####
Scanning dependencies of target raspicam_node
Scanning dependencies of target raspicam_raw_node
[ 25%] Building CXX object raspicam/CMakeFiles/raspicam_node.dir/src/raspicam_node.cpp.o
[ 50%] Building CXX object raspicam/CMakeFiles/raspicam_raw_node.dir/src/raspicam_raw_node.cpp.o
[ 75%] Linking CXX executable /tmp/raspicam_node_test/catkin_ws/devel/lib/raspicam/raspicam_raw_node
[100%] Linking CXX executable /tmp/raspicam_node_test/catkin_ws/devel/lib/raspicam/raspicam_node
/opt/vc/lib/libbcm_host.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
/opt/vc/lib/libbcm_host.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
raspicam/CMakeFiles/raspicam_raw_node.dir/build.make:174: recipe for target '/tmp/raspicam_node_test/catkin_ws/devel/lib/raspicam/raspicam_raw_node' failed
make[2]: *** [/tmp/raspicam_node_test/catkin_ws/devel/lib/raspicam/raspicam_raw_node] Error 1
raspicam/CMakeFiles/raspicam_node.dir/build.make:174: recipe for target '/tmp/raspicam_node_test/catkin_ws/devel/lib/raspicam/raspicam_node' failed
make[2]: *** [/tmp/raspicam_node_test/catkin_ws/devel/lib/raspicam/raspicam_node] Error 1
CMakeFiles/Makefile2:362: recipe for target 'raspicam/CMakeFiles/raspicam_raw_node.dir/all' failed
make[1]: *** [raspicam/CMakeFiles/raspicam_raw_node.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:783: recipe for target 'raspicam/CMakeFiles/raspicam_node.dir/all' failed
make[1]: *** [raspicam/CMakeFiles/raspicam_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
I'm assuming this is because the *.so objects in my /opt/vc/lib directory are compiled for ARM whereas my makefile is compiling for the localhost's architecture, which is amd64? How do I specify architecture in a CMakelist?