我有一个项目,它使用 opencv 库。今天我已将我的 Mac OS X Lion 升级到 Mavericks,现在我想知道为什么由于以下错误它不再编译:
c++ -O2 -g -Wall -fmessage-length=0 -c -o Hello.o Hello.cpp
Hello.cpp:2:10: fatal error: 'opencv/cv.h' file not found
#include "opencv/cv.h"
^
1 error generated.
make: *** [Hello.o] Error 1
这是Hello.cpp的代码:
#include <iostream>
#include "opencv/cv.h"
using namespace std;
int main(){
return 0;
}
这是我的生成文件:
CXXFLAGS = -O2 -g -Wall -fmessage-length=0
OBJS = Hello.o
LIBS = -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_gpu
INCPATH = -I/usr/local/Cellar/opencv/2.4.6.1/include
LIBPATH = -L/usr/local/Cellar/opencv/2.4.6.1/lib
TARGET = Hello
$(TARGET): $(OBJS)
g++ $(INCPATH) $(LIBPATH) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
我不得不说我可以通过键入以下内容使用终端编译我的项目:
g++ `pkg-config --cflags opencv` Hello.cpp -o Hello
可以肯定的是,这是我pkg-config --cflags opencv
在终端上运行得到的:
-I/usr/local/Cellar/opencv/2.4.6.1/include/opencv