친애하는 친구 나는 바보 같거나 매우 기초적인 질문을하는 경우 용서 해주십시오. 나는 3 일 동안 opencv를 사용하려고 노력 중이다. Qt와 XCODE에서 코드를 컴파일하는 것이 매우 어렵다는 것을 알았다. 어제 나는 많은 튜토리얼을 통해 gong을 실행 한 후 가장 기본적인 코드 중 하나를 얻을 수 있었다. 문제는 그러나 내가 이런 식으로 작성된 코드의 예를 찾을 일부 책에 있습니다OpenCv 컴파일 링 및 링크 오류
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char** argv) {
IplImage* img = cvLoadImage("/Users/mughery/Desktop/1_s.jpg");
cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1");
}
위의 코드는 내가 많이 얻을 우는 내가 코드를 테스트 할 때 그러나, 어떤 일이든 지금은 문제가 매우 잘 작동 오류가 발생했습니다. 나는 그들이 모두 C++ 코드이고 그들은 아마 같은 일을하고 있다고 생각한다.
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main()
{
//read an image
cv::Mat image = cv::imread("/Users/mughery/Desktop/1_s.jpg");
//create image window named "My Image"
cv::namedWindow("My Image");
cv::imshow("My image", image);
cv::waitKey(5000);
return 1;
}
내가 그것을 라이브러리를 찾을 수 없습니다라고 두 번째 코드를 실행
, 책은 동일한 라이브러리를 사용하는 두 그래서 뭐가 잘못 할 수있는 몇 가지 중 하나 개 도와주세요. 내가 두 번째 코드에서 받아 봐 오류는 1 - 당신이 모두 2에 대한 적절한 OpenCV의 라이브러리를 연결하고 있는지 확인 ... 아래 코드는 C++ 라이브러리를 사용하면서 첫 번째 코드는Ld /Users/mughery/Library/Developer/Xcode/DerivedData/Open-dvjwxosfuaihuabwnlxxuydfmyou/Build/Products/Debug/Open normal x86_64
cd /Users/mughery/Documents/ImageProgramtest/Open
export MACOSX_DEPLOYMENT_TARGET=10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/mughery/Library/Developer/Xcode/DerivedData/Open-dvjwxosfuaihuabwnlxxuydfmyou/Build/Products/Debug -L/usr/local/lib -F/Users/mughery/Library/Developer/Xcode/DerivedData/Open-dvjwxosfuaihuabwnlxxuydfmyou/Build/Products/Debug -filelist /Users/mughery/Library/Developer/Xcode/DerivedData/Open-dvjwxosfuaihuabwnlxxuydfmyou/Build/Intermediates/Open.build/Debug/Open.build/Objects-normal/x86_64/Open.LinkFileList -mmacosx-version-min=10.9 -stdlib=libstdc++ -lopencv_highgui.2.4.9 -lopencv_core.2.4.9 -Xlinker -dependency_info -Xlinker /Users/mughery/Library/Developer/Xcode/DerivedData/Open-dvjwxosfuaihuabwnlxxuydfmyou/Build/Intermediates/Open.build/Debug/Open.build/Objects-normal/x86_64/Open_dependency_info.dat -o /Users/mughery/Library/Developer/Xcode/DerivedData/Open-dvjwxosfuaihuabwnlxxuydfmyou/Build/Products/Debug/Open
Undefined symbols for architecture x86_64:
"cv::namedWindow(std::string const&, int)", referenced from:
_main in main.o
"cv::imread(std::string const&, int)", referenced from:
_main in main.o
"cv::imshow(std::string const&, cv::_InputArray const&)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
사용중인 컴파일러 또는 컴파일하는 컴퓨터를 변경 했습니까? –
아니, 아니, ii는 두 코드를 동시에 작동하고 다른 하나는 작동하지 않는다. – user3448232