Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCV, link error in XCode, Undefined symbols for architecture x86_64: "_cvHaarDetectObjects", referenced from: _main in main.o
    primarykey
    data
    text
    <p>I'm trying to use openCV (v 2.4.6) for macOSX (v 10.7.4) with Xcode (v 4.6.2).</p> <p>I've installed the library correctly (I guess, I haven't got any error so...) with cmake, after installation I've start a test project to render an image with success (following <a href="http://sadeepj.blogspot.it/2012/03/installing-and-configuring-opencv-to.html" rel="nofollow">this tutorial</a> for installation and test project):</p> <pre><code>#include &lt;iostream&gt; #include &lt;opencv2/opencv.hpp&gt; using namespace std; using namespace cv; int main (int argc, const char * argv[]) { Mat img = imread("/Users/username/path/image.jpg"); if (img.data == 0) { cerr &lt;&lt; "Image not found!" &lt;&lt; endl; return -1; } namedWindow("image", CV_WINDOW_AUTOSIZE); imshow("image", img); waitKey(); } </code></pre> <p>After this i've used code from an example found in the openCV library to do some more interesting with my test project (it should be a facetracker)</p> <pre><code>#include &lt;opencv2/opencv.hpp&gt; #include &lt;CoreFoundation/CoreFoundation.h&gt; #include &lt;cassert&gt; #include &lt;iostream&gt; const char * WINDOW_NAME = "Face Tracker"; const CFIndex CASCADE_NAME_LEN = 2048; char CASCADE_NAME[CASCADE_NAME_LEN] = "/Users/username/path/opencv/data/haarcascades/haarcascade_frontalface_alt2.xml"; using namespace std; int main (int argc, char * const argv[]) { const int scale = 2; // locate haar cascade from inside application bundle // (this is the mac way to package application resources) CFBundleRef mainBundle = CFBundleGetMainBundle (); assert(mainBundle); CFURLRef cascade_url = CFBundleCopyResourceURL (mainBundle, CFSTR("haarcascade_frontalface_alt2"), CFSTR("xml"), NULL); assert(cascade_url); Boolean got_it = CFURLGetFileSystemRepresentation (cascade_url, true, reinterpret_cast&lt;UInt8 *&gt;(CASCADE_NAME),CASCADE_NAME_LEN); if (! got_it) abort (); // create all necessary instances cvNamedWindow (WINDOW_NAME, CV_WINDOW_AUTOSIZE); CvCapture * camera = cvCreateCameraCapture (CV_CAP_ANY); CvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*) cvLoad (CASCADE_NAME, 0, 0, 0); CvMemStorage* storage = cvCreateMemStorage(0); assert (storage); // you do own an iSight, don't you ?!? if (! camera) abort (); // did we load the cascade?!? if (! cascade) abort (); // get an initial frame and duplicate it for later work IplImage * current_frame = cvQueryFrame (camera); IplImage * draw_image = cvCreateImage(cvSize (current_frame-&gt;width, current_frame-&gt;height), IPL_DEPTH_8U, 3); IplImage * gray_image = cvCreateImage(cvSize (current_frame-&gt;width, current_frame-&gt;height), IPL_DEPTH_8U, 1); IplImage * small_image = cvCreateImage(cvSize (current_frame-&gt;width / scale, current_frame-&gt;height / scale), IPL_DEPTH_8U, 1); assert (current_frame &amp;&amp; gray_image &amp;&amp; draw_image); // as long as there are images ... while ((current_frame = cvQueryFrame (camera))) { // convert to gray and downsize cvCvtColor (current_frame, gray_image, CV_BGR2GRAY); cvResize (gray_image, small_image, CV_INTER_LINEAR); // detect faces CvSeq* faces = cvHaarDetectObjects (small_image, cascade, storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize (30, 30)); // draw faces cvFlip (current_frame, draw_image, 1); for (int i = 0; i &lt; (faces ? faces-&gt;total : 0); i++) { CvRect* r = (CvRect*) cvGetSeqElem (faces, i); CvPoint center; int radius; center.x = cvRound((small_image-&gt;width - r-&gt;width*0.5 - r-&gt;x) *scale); center.y = cvRound((r-&gt;y + r-&gt;height*0.5)*scale); radius = cvRound((r-&gt;width + r-&gt;height)*0.25*scale); cvCircle (draw_image, center, radius, CV_RGB(0,255,0), 3, 8, 0 ); } // just show the image cvShowImage (WINDOW_NAME, draw_image); // wait a tenth of a second for keypress and window drawing int key = cvWaitKey (100); if (key == 'q' || key == 'Q') break; } // be nice and return no error return 0; } </code></pre> <p>This time there's something wrong, this is the error:</p> <pre><code>Ld /Users/winimac01/Library/Developer/Xcode/DerivedData/OpenCVDemo-cgklqgeatrdcvahjmnlypuyzqich/Build/Products/Debug/OpenCVDemo normal x86_64 cd /Users/winimac01/Desktop/IOSapp/sviluppo/OpenCVDemo setenv MACOSX_DEPLOYMENT_TARGET 10.7 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -L/Users/winimac01/Library/Developer/Xcode/DerivedData/OpenCVDemo-cgklqgeatrdcvahjmnlypuyzqich/Build/Products/Debug -F/Users/winimac01/Library/Developer/Xcode/DerivedData/OpenCVDemo-cgklqgeatrdcvahjmnlypuyzqich/Build/Products/Debug -filelist /Users/winimac01/Library/Developer/Xcode/DerivedData/OpenCVDemo-cgklqgeatrdcvahjmnlypuyzqich/Build/Intermediates/OpenCVDemo.build/Debug/OpenCVDemo.build/Objects-normal/x86_64/OpenCVDemo.LinkFileList -mmacosx-version-min=10.7 -lopencv_core -lopencv_highgui -lopencv_imgproc -stdlib=libstdc++ -framework CoreFoundation -lopencv_core.2.4.6 -lopencv_highgui.2.4.6 -o /Users/winimac01/Library/Developer/Xcode/DerivedData/OpenCVDemo-cgklqgeatrdcvahjmnlypuyzqich/Build/Products/Debug/OpenCVDemo Undefined symbols for architecture x86_64: "_cvHaarDetectObjects", 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) </code></pre> <p>Any ideas?</p> <p><strong>edit1:</strong></p> <p>Some info from Build Settings:</p> <pre><code>Architectures: 64-bit Intel Base SDK Latest: OSx (OSX 10.8) Valid Architectures: i386 x86_64 Other Linker Flags: none C Language Dialect: GNU99 [-std=gnu99] C++ Language Dialect: GNU++11 [-std=gnu++11] C++ Standard Library: libc++ (LLVM C++ standard library with C++) </code></pre> <p><strong>edit 2:</strong></p> <p>something interesting, compiling by terminal with </p> <pre><code>g++ `pkg-config --cflags --libs opencv` main.cpp </code></pre> <p>I receive this errors:</p> <pre><code>Package opencv was not found in the pkg-config search path. Perhaps you should add the directory containing `opencv.pc' to the PKG_CONFIG_PATH environment variable No package 'opencv' found Undefined symbols for architecture x86_64: "_CFBundleCopyResourceURL", referenced from: _main in cc6OpS79.o "_CFBundleGetMainBundle", referenced from: _main in cc6OpS79.o "_CFURLGetFileSystemRepresentation", referenced from: _main in cc6OpS79.o "___CFConstantStringClassReference", referenced from: CFString in cc6OpS79.o CFString in cc6OpS79.o "_cvCircle", referenced from: _main in cc6OpS79.o "_cvCreateCameraCapture", referenced from: _main in cc6OpS79.o "_cvCreateImage", referenced from: _main in cc6OpS79.o "_cvCreateMemStorage", referenced from: _main in cc6OpS79.o "_cvCvtColor", referenced from: _main in cc6OpS79.o "_cvFlip", referenced from: _main in cc6OpS79.o "_cvGetSeqElem", referenced from: _main in cc6OpS79.o "_cvHaarDetectObjects", referenced from: _main in cc6OpS79.o "_cvLoad", referenced from: _main in cc6OpS79.o "_cvNamedWindow", referenced from: _main in cc6OpS79.o "_cvQueryFrame", referenced from: _main in cc6OpS79.o "_cvResize", referenced from: _main in cc6OpS79.o "_cvShowImage", referenced from: _main in cc6OpS79.o "_cvWaitKey", referenced from: _main in cc6OpS79.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload