I downloaded the userland repository from https://github.com/raspberrypi/userland and I wanted to compile just RaspiVid.c file. It's because I wanted to use the RaspiVid.c code in my project. But i have problem with compilation even RaspiVid.c file itsel.

I'm tried use command g++ RaspiVid.c -lmmal_core -lmmal_util -lmmal_vc_client -lvcos -lbcm_host -lvcms -lvchq_arm -lpthread -o myRaspiVid for complation but it says that some files are missing.. When I copied files in the directory, there was problem with association (includes) of this files... Compiled on Raspberry Pi 2.

Is there some CMake pro that is able to resolve this problem and write me down some compile bash/make/cmake file?

Thanks for every response guys.

1 Answer 1


Compiling raspivid (or any of the raspicam apps) requires a lot more than just RaspiVid.c. Have a look at the top of that file and you'll see it also uses stuff from RaspiCamControl, RaspiPreview, and RaspiCLI, not to mention all the libraries it requires. Honestly, you're best off taking the pain of compiling userland in its entirety once. Then you can modify raspivid (and any of the stuff it depends upon) and recompiling it is just a matter of rebuilding the modified stuff.

The one thing I would note is that the default buildme script in the root of the repo is annoying in as much as it defaults to clobbering your existing installation of raspivid et al (after building it runs sudo make install on line 20):

if [ "armv6l" = `arch` ]; then
    make -j4
if [ "$1" != "" ]; then
 sudo make install DESTDIR=$1
 sudo make install

I always comment that chunk out and just use the resulting binaries directly from the build/raspberry/Release directory.

Still, if you're really desperate to build raspivid and only raspivid then the following command should do the trick (assuming your repo clone is in ~/userland):

gcc -o myraspivid RaspiVid.c RaspiCamControl.c RaspiPreview.c RaspiCLI.c \
    -I$HOME/userland -I$HOME/userland/host_applications/linux/libs/bcm_host/include \
    -L/opt/vc/lib -lbcm_host -lvcos -lpthread -lmmal_core -lmmal_util -lmmal_vc_client
  • "after building it runs sudo make install" -> SERIOUSLY?? What kind of goon does this...
    – goldilocks
    Nov 18, 2016 at 21:56
  • It only happens if you're building on the Pi (not if you're cross-compiling) so I guess the assumption is if you're compiling on the Pi, your SD card is your development platform for userland (not exactly hard to reflash the whole OS on the Pi after all). The practice would certainly surprise me on a non-embedded platform, but I can kind of understand it here (though I still don't like it, hence why I always comment that chunk out)
    – Dave Jones
    Nov 18, 2016 at 21:59

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.