Ask Your Question

Revision history [back]

installing OpenCV on Mac OSX

Mac os 10.8.2 opencv latest xcode command line tool latest gcc i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) brew version 0.9.4

I have installed openCV with homebrew, and setup paths for libraries. PKG_CONFIG_PATH=/usr/local/Cellar/opencv/2.4.3/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH DYLD_FALLBACK_LIBRARY_PATH=/usr/local/Cellar/opencv/2.4.3/lib:$DYLD_FALLBACK_LIBRARY_PATH

in .zshrc

But a simple code like

include "highgui.h"

int main(int argc, char** argv) {

IplImage* img = cvLoadImage( argv[1], CV_LOAD_IMAGE_COLOR ); cvNamedWindow("example1", CV_WINDOW_AUTOSIZE); cvShowImage("example2", img); cvWaitKey(0); cvReleaseImage(&img); cvDestroyWindow("example1"); }

fails to build

Could anyone help me install openCV properly?

the error message follows

Using built-in specs. Target: i686-apple-darwin11 Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~148/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~148/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/cc1 -quiet -v -imultilib x86_64 -iprefix /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/ -D__DYNAMIC__ example-2.1.c -fPIC -quiet -dumpbase example-2.1.c -mmacosx-version-min=10.8.2 -m64 -mtune=core2 -auxbase example-2.1 -version -o /var/folders/hk/1clspzcd49d173p3pvpk1f3w0000gn/T//ccSUavgW.s ignoring nonexistent directory "/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"

include "..." search starts here:

include <...> search starts here:

/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include /usr/local/include /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) (i686-apple-darwin11) compiled by GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00). GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=131072 Compiler executable checksum: 72ea1d123312df92a792c3841e21247d /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/as -arch x86_64 -force_cpusubtype_ALL -o /var/folders/hk/1clspzcd49d173p3pvpk1f3w0000gn/T//ccZeGswn.o /var/folders/hk/1clspzcd49d173p3pvpk1f3w0000gn/T//ccSUavgW.s /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/collect2 -dynamic -arch x86_64 -macosx_version_min 10.8.2 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64 -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1 -L/usr/llvm-gcc-4.2/bin/../lib/gcc -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1 -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../.. -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../.. /var/folders/hk/1clspzcd49d173p3pvpk1f3w0000gn/T//ccZeGswn.o -lSystem -lgcc -lSystem Undefined symbols for architecture x86_64: "_cvAddS", referenced from: _cvSubS in ccZeGswn.o "_cvDestroyWindow", referenced from: _main in ccZeGswn.o "_cvEllipse", referenced from: _cvEllipseBox in ccZeGswn.o "_cvFree_", referenced from: _cvDecRefData in ccZeGswn.o "_cvGetCols", referenced from: _cvGetCol in ccZeGswn.o "_cvGetFileNodeByName", referenced from: _cvReadIntByName in ccZeGswn.o _cvReadRealByName in ccZeGswn.o _cvReadStringByName in ccZeGswn.o _cvReadByName in ccZeGswn.o "_cvGetRows", referenced from: _cvGetRow in ccZeGswn.o "_cvGetSeqElem", referenced from: _cvGetSetElem in ccZeGswn.o "_cvInitFont", referenced from: _cvFont in ccZeGswn.o "_cvLoadImage", referenced from: _main in ccZeGswn.o "_cvNamedWindow", referenced from: _main in ccZeGswn.o "_cvRead", referenced from: _cvReadByName in ccZeGswn.o "_cvReleaseImage", referenced from: _main in ccZeGswn.o "_cvReleaseMat", referenced from: _cvReleaseMatND in ccZeGswn.o "_cvSeqSlice", referenced from: _cvCloneSeq in ccZeGswn.o "_cvSetAdd", referenced from: _cvSetNew in ccZeGswn.o "_cvShowImage", referenced from: _main in ccZeGswn.o "_cvWaitKey", referenced from: _main in ccZeGswn.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status