3

I have a cross compiler that allows me to compile code on Mac OS x 10.7 and produce binaries for the Raspberry Pi.

Compiling simple "helloworld.cpp" programs works like this:

/usr/bin/raspi-g++/helloworld.cpp

which produces "a.out" that successfully executes on the pi.

However, I'm a little unclear how do proceed with my cross-compiler when producing OpenCV binaries for the raspberry pi.

Some background information:

  • I have built from source Open CV 2.3.1 on the Raspberry Pi without using the cross compiler and following these instructions: http://mitchtech.net/raspberry-pi-opencv/. Yes it took approx. 4 hours to build OpenCV.

  • I have built from source Open CV 2.3.1 on my Mac OS x 10.7 (took less than a few minutes)

I just don't know how to connect both of the above using my cross compiler?

Do I need to rebuild Open CV 2.3.1 on my Mac but instead of using the g++ that comes with OS X force cmake to use my cross compiler?

Would something like this work:

CC=/usr/bin/raspi-gcc CXX=/usr/bin/raspi-g++ -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..

Would appreciate all / any advise.

1 Answer 1

3

There are some different ways to approach the problem.

A first hacky way to proceed would be to copy the libraries you built on the RPi on your PC and link your software against them.

Another strategy would be to cross-compile OpenCV to have it on your PC. Something like the command you proposed would work. I experimented with cross compiling CMake enabled projects a while back by using toolchain files CMake (as reported on my blog here).

Another approach could be to to share RPi local /usr/local/lib over NFS and point the linker to that folder, but I'm not quite sure how effective this could be.

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.