In September 2014, I documented how to compile EmguCV on the Raspberry Pi. At the time I didn't even know if it would work and so hacked away removing code and compile errors until it finally compiled.

My old Pi died before Christmas and the model B replacement needed a new compile of EmguCV. Here is how I did it this time, in a more refined manner.

Install Mono

This time I compiled mono 3.12.0 from a tarball download. The sudo apt-get upgrade method for Debian didn't work on the pi with 'you have held broken packages' errors. I added an export to ~/.profile to make the path to the mono bin folder persist through reboots.

Compile EmguCV

Update April 2015: See these newer instructions

This time I used EmguCV master from commit 0a47c32492c336cedecdc191459956f67ad64edc from January 15 2015.

As before, this is documenting deviations from the Ubuntu 14.04 compile instructions.

The first deviation is to cmake in which we turn a few extra things off in the compile.


After cmake is configured, make is executed and after some time this error happened:

In file included from /home/pi/emgucv/Emgu.CV.Extern/vector_ERStat.cpp:10:0:
/home/pi/emgucv/Emgu.CV.Extern/vector_ERStat.h:17:37: fatal error: opencv2/text/erfilter.hpp: No such file or directory
compilation terminated.
Emgu.CV.Extern/CMakeFiles/cvextern.dir/build.make:701: recipe for target 'Emgu.CV.Extern/CMakeFiles/cvextern.dir/vector_ERStat.cpp.o' failed
make[2]: *** [Emgu.CV.Extern/CMakeFiles/cvextern.dir/vector_ERStat.cpp.o] Error 1
CMakeFiles/Makefile2:4468: recipe for target 'Emgu.CV.Extern/CMakeFiles/cvextern.dir/all' failed
make[1]: *** [Emgu.CV.Extern/CMakeFiles/cvextern.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

The fix was

mkdir -p ./Emgu.CV.Extern/opencv2/text
cp ./opencv_contrib/modules/text/include/opencv2/text/erfilter.hpp ./Emgu.CV.Extern/opencv2/text

After that, there was only one more error.

Linking CXX shared library ../bin/
[100%] Built target cvextern
Linking CXX executable ../../bin/cvextern_test
../../bin/ undefined reference to `cv::text::ERStat::ERStat(int, int, int, int)'
collect2: ld returned 1 exit status
tests/cvextern_test/CMakeFiles/cvextern_test.dir/build.make:115: recipe for target 'bin/cvextern_test' failed
make[2]: *** [bin/cvextern_test] Error 1
CMakeFiles/Makefile2:3288: recipe for target 'tests/cvextern_test/CMakeFiles/cvextern_test.dir/all' failed
make[1]: *** [tests/cvextern_test/CMakeFiles/cvextern_test.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

Interestingly this is ERStat again. This time I removed these lines from the root CMakeLists.txt


Run cmake and then make and EmguCV compiles successfully.