OpenCV Undefined symbols for x86_64 architecture after upgrading to OS X Mavericks

I had an opencv project that worked fine. Today I upgraded my OS X lion to Maverick, and I got the following error for the imwrite function:

Undefined symbols for architecture x86_64:
  "cv::imwrite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
      _main in Hello.o
ld: symbol(s) not found for architecture x86_64

I have to say that other opencv functions still work (e.g. cvWaitKey (), cvShowImage, etc.), but imwrite and imread no longer work.

You can see the make file that I use below:

CXX = g++
CXXFLAGS = -O2 -g -Wall -fmessage-length=0 
CPPFLAGS = -I/usr/local/Cellar/opencv/2.4.6.1/include

OBJS =      Hello.o

LDFLAGS = -L/usr/local/Cellar/opencv/2.4.6.1/lib
LDLIBS =  -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video \
          -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect \
          -lopencv_contrib -lopencv_legacy -lopencv_gpu

TARGET =    Hello

.PHONY: all
all: $(TARGET)
$(TARGET):  $(OBJS)
         $(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@

.PHONY: clean
clean:
        rm -f $(OBJS) $(TARGET)

Solution: I solved the problem by installing opencv 2.4.3. You can find more details in the answer I added.

+4
source share
3 answers

, opencv 2.4.6.1. opencv 2.4.3 Cmake , :

tar -xf opencv-2.4.3.tar.gz
cd opencv-2.4.3
echo "#define GTEST_USE_OWN_TR1_TUPLE 1" | cat > temp1
cat modules/ts/include/opencv2/ts/ts_gtest.h > temp2
cat temp1 temp2 > modules/ts/include/opencv2/ts/ts_gtest.h
mkdir build
cd build
cmake .. -Wno-dev
make -j8 && sudo make install

P.S: opencv homebrew,

0

, -mmacosx-version-min=10.8 g++. , .

+3

, . , 64- 64- , debug libs .. : opencv ? 2,3? , , ,

Also, to clarify, imread and imwrite do not work only in debugging or debugging and release?

I hope my answers have helped you. Let me know if there is a problem.

0
source

All Articles