3

I'm trying to install opencv and use it with xCode for making application in C++. I installed it using macports and follow many tutorials to do it. I have done the linking too in xcode but there is problems that some function dosen't work. it give an error like Undefined symbols for architecture x86_64:

cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)", 
"cv::floodFill(cv::_OutputArray const&, cv::Point_<int>, cv::Scalar_<double>, cv::Rect_<int>*, cv::Scalar_<double>, cv::Scalar_<double>, int)

If I switch the build arch to 32 bits, it gives the same error with more functions.

any idea ? I try to delete macports with opencv and install it using homebrew in 32 bits build but homebrew cannot install it for unknown error. so is the library not 64 bits compatible ?

Tyler Hyndman
  • 1,402
  • 3
  • 17
  • 24
Mujtaba Alboori
  • 395
  • 1
  • 7
  • 20

1 Answers1

2

I got OpenCV 2.3.0 installed on my Mac through my favorite way, which is download the source code and compile it:

tar -xzvf OpenCV-2.3.0.tar.bz2
cd OpenCV-2.3.0
mkdir build
cd build
cmake ../

-- Extracting svn version, please wait...
-- SVNVERSION: 
-- Detected version of GNU GCC: 42 (402)
-- checking for module 'libdc1394-2'
--   package 'libdc1394-2' not found
-- checking for module 'libdc1394'
--   package 'libdc1394' not found
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.3")
-- Found PythonInterp: /usr/bin/python2.6 (found version "2.6.1")
--     Use NumPy headers from: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/core/include
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named sphinx
-- CUDA detected: 4.0
-- CUDA NVCC target flags: -gencode;arch=compute_11,code=sm_11;-gencode;arch=compute_12,code=sm_12;-gencode;arch=compute_13,code=sm_13;-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_20,code=compute_20
-- Parsing 'cvconfig.h.cmake'
-- 
-- General configuration for opencv 2.3.0 =====================================
-- 
--     Built as dynamic libs?:     ON
--     Compiler:                   
--     C++ flags (Release):        -m32  -Wall -pthread -march=i386  -O3 -DNDEBUG  -fomit-frame-pointer -ffast-math -msse -msse2 -DNDEBUG 
--     C++ flags (Debug):          -m32  -Wall -pthread -march=i386  -g  -O0 -DDEBUG -D_DEBUG -ggdb3 
--     Linker flags (Release):      
--     Linker flags (Debug):        
-- 
--   GUI: 
--     Cocoa:                      YES
-- 
--   Media I/O: 
--     ZLib:                       TRUE
--     JPEG:                       TRUE
--     PNG:                        TRUE
--     TIFF:                       TRUE
--     JPEG 2000:                  TRUE
--     OpenEXR:                    NO
--     OpenNI:                     FALSE
-- 
--   Video I/O:                    QTKit
-- 
--   Interfaces: 
--     Python:                     ON
--     Python interpreter:         /usr/bin/python2.6
--     Python numpy:               YES
--     Use IPP:                    NO
--     Use TBB:                    NO
--     Use ThreadingFramework:     NO
--     Use Cuda:                   YES
--     Use Eigen:                  NO
-- 
--   Documentation: 
--     Build Documentation:        NO
-- 
--     Install path:               /usr/local
-- 
--     cvconfig.h is in:           /Users/karlphillip/installers/OpenCV-2.3.0/build
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/karlphillip/installers/OpenCV-2.3.0/build

Then:

make
sudo make install

And there it is:

$ pkg-config --cflags --libs opencv
-I/usr/local/include/opencv -I/usr/local/include  -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

Note: if you need to install any dependencies, use brew!

And all OpenCV libs are x86_64:

$ file /usr/local/lib/libopencv_highgui.dylib 
/usr/local/lib/libopencv_highgui.dylib: Mach-O 64-bit dynamically linked shared library x86_64

$ file /usr/local/lib/libopencv_imgproc.dylib 
/usr/local/lib/libopencv_imgproc.dylib: Mach-O 64-bit dynamically linked shared library x86_64

I suggest you remove the current OpenCV installation and make sure there is nothing left in your system before downloading and compiling it from scratch.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • @JesseB To fix the pkg-config error you saw, read [this post](http://opencv.willowgarage.com/wiki/CompileOpenCVUsingLinux). Anyway, at this point you should try to compile any OpenCV application manually (on the cmd-line), without using XCode. This will help you isolate if the problem is in XCode or if it's the installed libs. – karlphillip Dec 14 '11 at 18:44