2

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?

1 Answer 1

1

Raspberry Pi specific files have no purpose on other platforms, that's why Ubuntu is not hosting them.

VideoCore OS files can be found here.

2
  • That has some of the includes, but not all. I'm still missing bcm_host.h. Googling shows that's included in the package libraspberrypi-dev, but that package is only available on Raspbian, not Ubuntu.
    – Cerin
    Feb 8, 2017 at 2:02
  • @Cerin I suggest you limit your search to RPi github. I have found bcm_host.h twice there: here and here. Not sure which one you may need though. Feb 8, 2017 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.