升级到OS X Mavericks之后,体系结构x86_64的OpenCV未定义符号 [英] OpenCV Undefined symbols for architecture x86_64 after upgrading to OS X Mavericks

查看:109
本文介绍了升级到OS X Mavericks之后,体系结构x86_64的OpenCV未定义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行良好的opencv项目.今天,我已将OS X Lion升级到Maverick,并且在写入功能时遇到以下错误:

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

我不得不说其他opencv函数仍在起作用(例如cvWaitKey(),cvShowImage等),但是imwrite和imread不再起作用.

I have to say that other opencv functions are still working (e.g. cvWaitKey(), cvShowImage, etc) but imwrite and imread do not work anymore.

您可以在下面看到我使用的makefile:

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)

解决方案: 我已经通过安装opencv 2.4.3解决了这个问题.您可能会在我添加的答案中找到更多详细信息.

Solution: I've solved the problem by installing opencv 2.4.3. You might find more detail in the answer, which I've added.

推荐答案

正如Yang在评论之一中提到的那样,问题出在opencv 2.4.6.1.我已经使用 Cmake安装程序 :

As Yang mentioned in one of the comments, the problem comes from opencv 2.4.6.1. I have installed opencv 2.4.3 using Cmake installer by running the following, and it works:

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

PS:我无法使用自制软件安装任何旧版本的opencv,您可以在此处

P.S: I could not install any old version of opencv using homebrew, you can see here

这篇关于升级到OS X Mavericks之后,体系结构x86_64的OpenCV未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆