[英]C compiling progam that uses OpenCV library with Makefile
Hi I have project in CLion
written in C language that uses OpenCV library . 嗨,我
CLion
C语言编写的CLion
项目,它使用OpenCV库 。 I have configured it with CMake
and it compiles and runs very well. 我已经用
CMake
配置了它,并且可以编译并很好地运行。 But I also have my own Makefile
in directory, now I would like to add to this Makefile support for OpenCV library . 但是我在目录中也有我自己的
Makefile
,现在我想添加到OpenCV库的 Makefile 支持中 。
Here are lines I have added to this Makefile: 这是我添加到此Makefile中的行:
# libraries
# OpenCV
OPENCV_CFLAGS = `pkg-config —-cflags opencv`
OPENCV_LIBS = `pkg-config —-libs opencv`
and then: 接着:
$(TARGET): main.c $(LIBRARY) $(TEST_SOURCE_FILES)
$(CC) $(CFLAGS) -o $(TARGET) main.c $(LIBRARY) $(TEST_SOURCE_FILES) $(UNIT_TESTS_LIBRARY) $(OPENCV_LIBS) $(OPENCV_CFLAGS)
While I am doing make -f make.txt
it doesn't compile and the problem is: 当我执行
make -f make.txt
它无法编译,问题是:
fatal error: 'cv.h' file not found
#include <cv.h>
I also try to use this: 我也尝试使用这个:
# include headers
CFLAGS += -I/usr/local/include/opencv
But despite cv.g has been found there is another error: 但是,尽管找到了cv.g,仍然存在另一个错误:
/usr/local/include/opencv/cv.h:63:10: fatal error: 'opencv2/core/core_c.h' file not found
#include "opencv2/core/core_c.h"
No I changed this to: 不,我将其更改为:
# include headers
CFLAGS += -I/usr/local/include
and also #include<cv.h>
to #include<opencv/cv.h>
no there no error message about not found header files, but some linking problems like this: 并且
#include<cv.h>
到#include<opencv/cv.h>
也没有关于未找到头文件的错误消息,但是有些链接问题是这样的:
Undefined symbols for architecture x86_64:
"_cvCreateImage", referenced from:
Ok I have solved the problem I make this in Makefile: 好的,我已经解决了我在Makefile中创建的问题:
# include headers
# CFLAGS += -I/usr/local/include
# libraries
# OpenCV
OPENCV_LIBS = `pkg-config --cflags --libs opencv`
and than while compiling target: 并且比编译目标时:
$(TARGET): main.c $(LIBRARY) $(TEST_SOURCE_FILES)
$(CC) $(CFLAGS) -o $(TARGET) main.c $(LIBRARY) $(TEST_SOURCE_FILES) $(UNIT_TESTS_LIBRARY) $(OPENCV_LIBS)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.