I had a opencv project which was working fine. Today I have upgraded my OS X lion to Maverick and I get 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 are still working (e.g. cvWaitKey(), cvShowImage, etc) but imwrite and imread do not work anymore.
You can see the makefile which 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've solved the problem by installing opencv 2.4.3. You might find more detail in the answer, which I've added.