Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9881 Discussions

how to compile opencv using g++ for intel edison

New Contributor I

hi i am currently doing a project that requires both mraa and opencv, my question is how do i compile a program using g++

for example for just using mraa the g++ compile looks something like this : g++ -lmraa -o sample sample.cpp

so how do i complie with mraa and opencv, i have been gettting all kinds of errors compiling.

p.s i have installed opencv in my intel edison by following this tutorial :

7 Replies
Community Manager

Hi Prashanth93,

Could you please copy and paste here the command that you're using to compile the openCV program and the output that you're getting? It might be an issue with a library, like this case: /thread/75235, where a library was missing at the time of compilation, so the simplest solution was to remove the aforementioned library. Check out the thread and let us know if that helps, also remember to share the command and the output.



New Contributor I

------------------------ this is the error message im getting------------------------------------------------------------------------------

/tmp/ccDQvlDL.o: In function `cv::Mat::~Mat()':

camread.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x2f): undefined reference to `cv::fastFree(void*)'

/tmp/ccDQvlDL.o: In function `cv::Mat::create(int, int, int)':

camread.cpp:(.text._ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x6e): undefined reference to `cv::Mat::create(int, int const*, int)'

/tmp/ccDQvlDL.o: In function `cv::Mat::release()':

camread.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x38): undefined reference to `cv::Mat::deallocate()'

collect2: error: ld returned 1 exit status


-----------------------this is the code im trying to compile---------------------------------------------------------------------------------

# include

# include

# include

# include

# include

using namespace std;

using namespace cv;

int main(){


mraa_gpio_context d0;

mraa_gpio_context d1;

mraa_gpio_context d2;

mraa_gpio_context d3;

mraa_gpio_context d4;

mraa_gpio_context d5;

mraa_gpio_context d6;

mraa_gpio_context d7;

mraa_gpio_context vsync;

mraa_gpio_context href;

mraa_gpio_context pclk;

d0 = mraa_gpio_init(2);

d1 = mraa_gpio_init(3);

d2 = mraa_gpio_init(4);

d3 = mraa_gpio_init(5);

d4 = mraa_gpio_init(6);

d5 = mraa_gpio_init(7);

d6 = mraa_gpio_init(8);

d7 = mraa_gpio_init(9);

pclk = mraa_gpio_init(10);

href = mraa_gpio_init(11);

vsync = mraa_gpio_init(12);

mraa_gpio_dir(d0, MRAA_GPIO_IN);

mraa_gpio_dir(d1, MRAA_GPIO_IN);

mraa_gpio_dir(d2, MRAA_GPIO_IN);

mraa_gpio_dir(d3, MRAA_GPIO_IN);

mraa_gpio_dir(d4, MRAA_GPIO_IN);

mraa_gpio_dir(d5, MRAA_GPIO_IN);

mraa_gpio_dir(d6, MRAA_GPIO_IN);

mraa_gpio_dir(d7, MRAA_GPIO_IN);

mraa_gpio_dir(href, MRAA_GPIO_IN);

mraa_gpio_dir(vsync, MRAA_GPIO_IN);

mraa_gpio_edge_mode(pclk, MRAA_GPIO_EDGE_RISING);

int data[7];

int byte;

int counter = 0;

Mat image(480,640,CV_8UC1);


int shref = mraa_gpio_read(href);

int svsync = mraa_gpio_read(vsync);

int fpclk = mraa_gpio_read(pclk);

if (svsync==0 && shref==1 && fpclk==1){

data[0] = mraa_gpio_read(d0) ;

data[1] = mraa_gpio_read(d1) ;

data[2] = mraa_gpio_read(d2) ;

data[3] = mraa_gpio_read(d3) ;

data[4] = mraa_gpio_read(d4) ;

data[5] = mraa_gpio_read(d5) ;

data[6] = mraa_gpio_read(d6) ;

data[7] = mraa_gpio_read(d7) ;

byte = (data[7]<<7) | (data[6]<<6) | (data[5]<<5) | (data[4]<<4) |

(data[3]<<3) | (data[2]<<2) | (data[1]<<1) | (data[0]) ;

if(counter == 1) {

//do gray scale input to mat container


else if(counter == 2){

counter = 0;









the command i use to compile is : g++ -lmraa -lopencv_highgui -lopencv_core -lopencv_imgproc -o camread camread.cpp


and i also checked the forum you linked to regarding the library issue, and when i went to my /usr/lib/pkgconfig/ folder in my edison i couldnt find the opencv.pc file. this could also be a reason why im getting the error message

Community Manager

Hi Prashanth93,



I would like to give it a try myself. I'm not sure if there's an error with the libraries or with the code. I would also like to set up OpenCV on my Intel Edison to see if this is an error with your installation or maybe with the installation process itself. Have you tried using python before? While I run some tests you can play with python to see if you get different results.





Community Manager

Hi Prashanth93,



I've been trying to make your code work using this guide to install OpenCV, However, I've been unable to get it working. First I had some troubles with this line "namespace cv" but it was some installation issue, once I encountered the error I tried to compile your program once more and encountered a similar error message to the one you're getting.


After that, I used AlexT repository to install OpenCV (the only drawback is that it is v2.4) and got a successful compilation using this process. I would suggest to try this way and you might get better results.





New Contributor I

thanks pablo,

but how to install opencv from the alexT repo also i saw his repo list in the /etc/opkg/base-feeds.conf to be identical to whats already in my edison.

which are the :

src/gz all

src/gz edison

src/gz core2-32

and how do i install opencv form the repository ?

Community Manager

Hi Prashanth,



You'll just need to use the command opkg install name-of-the-package, with this you'll start fetching the package from the repository and then you'll install it. Take a look at his repository packages in here, go to core2-32/ and search for all the openCV available packages (development tools and libraries).


If you're willing to give Python a try you can check this guide which contains some useful information about openCV and Python,





New Contributor I

yup i finally got opencv working, truns out it was quite easy to configure, unlike the intel documentation... which only irritates me how misleading the whole thing is. intel should really do a better job at providing better documnetation

anyhow heres what i did i went to alexT repo, followed the instruction there( Edison Package Repo Configuration Instructions )

then i typed in

opkg install opencv

opkg install libopencv-core2.4

opkg install libopencv-core-dev

and that was it !!

i could compile my code using "g++ -lopencv_highgui -lopencv_core -lopencv_imgproc -lopencv_objdetect -lmraa -o facecount facecount.cpp"

since and succssfully ran a haar casscade code to count number of faces

thanks a million Pablo,

i couldnt have done it without your help !!!