我正在建立一臺OpenCV 2.3.1的新機器。該機器是Windows 7機器,我遵循OpenCV網站(使用CMake和MinGW構建)提供的安裝說明。OpenCV你好,世界不編譯它應該
這裏是我的代碼:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main() {
char var;
cv::Mat img;
img = cv::imread("C:/test/img.jpg");
cv::namedWindow("Image");
cv::imshow("Image", img);
std::cin >> var;
return 1;
}
這裏是我的make命令:
g++ -o main main.cpp -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy
這裏是我的路徑:
C:\OpenCV-2.3.1\install\bin;C:\OpenCV-2.3.1\install\include;C:\QtSDK\QtCreator\bin;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake 2.8\bin;C:\QtSDK\mingw\bin;
這裏是我的錯誤:
main.cpp:2:33: error: opencv2/core/core.hpp: No such file or directory
main.cpp:3:39: error: opencv2/highgui/highgui.hpp: No such file or directory
main.cpp: In function 'int main()':
main.cpp:8: error: 'cv' has not been declared
main.cpp:8: error: expected ';' before 'img'
main.cpp:9: error: 'img' was not declared in this scope
main.cpp:9: error: 'cv' has not been declared
main.cpp:10: error: 'cv' has not been declared
main.cpp:11: error: 'cv' has not been declared
這是沒有道理的。爲什麼不能編譯?爲什麼找不到opencv2/core/core.hpp?
你能不能張貼一個鏈接到你的指令遵循? –