OpenCV 2.4.2 took 6 hours to compile on the Raspberry Pi and I'd love to package everything up as a deb but I have never done that before. How can I package the compiled files so that they download or include the necessary other libraries?

  • Is this more a Linux specific question rather than a Pi related one? Maybe better asking on Debain about it?
    – ppumkin
    Aug 22, 2012 at 16:32
  • Hi there. Since this is generic Debian, would you mind if I moved this to Ask Ubuntu or Unix & Linux?
    – Jivings
    Aug 22, 2012 at 17:15
  • @Jivings I think it is PI related since I don't know anything about hard float vs soft float and I know there are caveats with Pi regarding that. If there is a general consensus that someone there could help answer this question I have no problem with it being moved
    – onlinemarketresults
    Aug 22, 2012 at 17:59
  • This page should have all of the information and tutorials you need: wiki.debian.org/Packaging
    – Jim Paris
    Aug 23, 2012 at 17:43

2 Answers 2


I thought I would add a better answer for anyone else observing this thread.

So, if you've already gone through the trouble of building opencv on the device, you've probably followed the instructions here:


In which case, if you don't add the -D args to dynamically override CMake parameters in step two and you instead just run cmake .. inside the build directory (you created), it will generate a CMakeCache.txt file.

If you edit the CMakeCache.txt file, you can change:


...in addition to the other specified variables in the above opencv link. Instead of running make or make install... just run make package and the magic happens.

Warning: If you have WITH_CUDA:BOOL=ON you may have dependency issues with the packager - and that's a totally different question...

For more info see the CPACK_*_*:BOOL parameters in the cmake files, and consult the CPack documentation:


  • This produces a couple of .deb files, a couple of tar files and a script. Which of these need to be distributed to and run on a target system? All? Do they need any supporting files?
    – Alex
    Mar 21, 2016 at 23:39
  • @Alex, forgot about this post last year. So, you should have OpenCV-*-{libs,dev}.deb You need both. I think dev has the headers ld uses to link against the .so in libs. You can also figure this out by running dpkg -c OpenCV-*.deb on the package, to list the contents. Also, if you created this from source.tar, you may not have a version number and dpkg -i $pkg will not like this. You can tell if it says OpenCV-unknown-*{dev,libs}.deb In which case git clone github.com/Itseez/opencv and git checkout $tag in the releases tab. If you build from top of tree, you also get tag on deb.
    – hhony
    Mar 23, 2016 at 16:42
  • No need to edit the CMakeCache.txt file manually...just rerun cmake with the right arg, i.e. cmake -DCPACK_BINARY_DEB=ON ... or use the ccmake user interface. Jan 18 at 23:26

If by OpenCV you mean the computer vision libraries at http://opencv.willowgarage.com/ then they are already packaged for debian by the Debian Science Team.

Your best bet is to download the debianised source package from your nearest debian mirror, modify the debian/rules and/or Makefile or configure etc as needed to compile correctly on the raspberry pi and rebuild the packages.

The packaging work is already done, there's no need to do it again....and again and again every time your want to update them.

There's a whole bunch of binary packages, but libopencv-dev is probably what you want to start with http://packages.debian.org/search?keywords=libopencv-dev

  • Will the published packages work on an ARM architecture like the Raspberry Pi? I wish I better understood packages and dependencies but it would seem to me that unless willowgarage released a package specifically for the processor in the Raspberry Pi then their packages will not work.
    – Dan B
    Aug 27, 2012 at 14:03
  • You must have misread what I wrote. I said to download the debian SOURCE packages and recompile for Raspberry Pi. 'onlinemarketresults' already has a RPi compilation (or cross-compilation) environment set up and knows how to compile for RPi, he just wanted to know how to make a package.
    – cas
    Aug 27, 2012 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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