在 64 位 Mac 上编译 OpenCV 代码
我最近继承了一些OpenCV代码。我在我的 mac 上安装了 openCV,内置在 XCode 中,然后编译并成功运行了我的第一个 openCV“hello world”程序。
现在,我尝试运行给定的代码,但出现错误,这让我相信这是在 32 位 Windows 系统上运行的原始代码和在 64 位 Mac 上运行的原始代码的问题。
当我通过输入“make”运行 Makefile 时,
CC = g++
CFLAGS =
LDFLAGS = -I/usr/local/include/opencv -lm -lopencv_core -lopencv_highgui -lopencv_video
ALL = vision
all: $(ALL)
vision: vision.o
$(CC) $(LDFLAGS) -o $@ $^
vision.o: vision.cpp
$(CC) $(LDFLAGS) -c $<
.PHONY: clean
clean:
rm -rf *.o core* $(ALL)
我得到以下输出……
g++ -I/usr/local/include/opencv -lm -lopencv_core -lopencv_highgui -lopencv_video -o vision vision.o
Undefined symbols for architecture x86_64:
"cv::equalizeHist(cv::Mat const&, cv::Mat&)", referenced from:
_main in vision.o
"cv::threshold(cv::Mat const&, cv::Mat&, double, double, int)", referenced from:
_main in vision.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [vision] Error 1
我很困惑;这是否意味着我安装的 OpenCV 是错误的,代码(特别是那些方法)需要更改,或者完全是其他什么?
注意:当我从 Vision.cpp 代码中注释掉问题方法时,一切都可以正常编译。
I recently inherited some OpenCV code. I installed openCV on my mac, built in in XCode, and then compiled and successfully ran my first openCV "hello world"-ish program.
Now I'm trying to run the code I was given, but I get errors that lead me to believe it's an issue with the original code being run on a 32-bit Windows system and mine being on a 64-bit Mac.
When I run the Makefile by entering "make"
CC = g++
CFLAGS =
LDFLAGS = -I/usr/local/include/opencv -lm -lopencv_core -lopencv_highgui -lopencv_video
ALL = vision
all: $(ALL)
vision: vision.o
$(CC) $(LDFLAGS) -o $@ $^
vision.o: vision.cpp
$(CC) $(LDFLAGS) -c lt;
.PHONY: clean
clean:
rm -rf *.o core* $(ALL)
I get the following output…
g++ -I/usr/local/include/opencv -lm -lopencv_core -lopencv_highgui -lopencv_video -o vision vision.o
Undefined symbols for architecture x86_64:
"cv::equalizeHist(cv::Mat const&, cv::Mat&)", referenced from:
_main in vision.o
"cv::threshold(cv::Mat const&, cv::Mat&, double, double, int)", referenced from:
_main in vision.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [vision] Error 1
I'm confused; does this mean my install of OpenCV is wrong, the code (those methods specifically) needs to be changed, or something else entirely?
Note: When I comment out the problem methods from the vision.cpp code, everything compiles just fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
opencv_imgproc
添加到您的 LDFLAGS:Add
opencv_imgproc
to your LDFLAGS:这是一个工作示例:
Here is a working example:
您还可以让计算机自动猜测您的库:
You can also have the computer guess you the libraries automatically: