The following C++ programs cannot be compiled. What is the cause?
#include "stdio.h"
# include "highgui.h"
# include "cv.h"
int main(intargc, char**argv){
IplImage*img=cvLoadImage(argv[1]);
cvNamedWindow("scrot.png", CV_WINDOW_AUTOSIZE);
cvShowImage("scrot.png", img);
cvReleaseImage(&img);
cvDestroyWindow("scrot.png");
}
reg++-Wall-o "rei2-1" "rei2-1.cpp" (directory: /home/pi/Desktop/C)/tmp/ccWxBQc9.o:In function main':
rei2-1.cpp: (.text+0x28): Undefined reference to cvLoadImage'
rei2-1.cpp: (.text+0x3c): Undefined reference to cvNamedWindow'
rei2-1.cpp: (.text+0x4c): Undefined reference to cvShowImage'
rei2-1.cpp: (.text+0x58): Undefined reference to cvReleaseImage'
rei2-1.cpp: (.text+0x60): Undefined reference to cvDestroyWindow'
collect2:error:ld returned1 exit status compilation failure –
·Open Geany on the desktop version of Raspberry Pi and press the compilation button there.
·OpenCV version is 3.4.1.
When trying to call OpenCV functions, it appears that "Definition not found" is an error, but the Include
is written differently depending on the OpenCV version.
If you use 2.x
or later, use the include
section.
#include<opencv/cv.h>
# include <opencv/cxcore.h>
# include <opencv/highgui.h>
You should also include the opencv/*
subdirectory name as shown in .
Note:
http://hikopatchi.hatenablog.com/entry/2014/03/31/184937
https://github.com/opencv/opencv/tree/3.4/include/opencv
© 2024 OneMinuteCode. All rights reserved.