1
我對Ubuntu的,其文件夾結構是一些OpenCV的C++代碼:不能編譯,利用makefile
|-- bin
| |-- camera-calib.o
| `-- frontalize.o
|-- docs
| `-- notes.md
|-- LICENSE.md
|-- Makefile
|-- README.md
|-- shape_predictor_68_face_landmarks.dat
`-- src
|-- calib
| |-- calib.cpp
| |-- calib.h
| |-- POSIT.cpp
| |-- POSIT.h
| |-- pro
| | |-- calib.o
| | |-- Makefile
| | |-- POSIT.o
| | |-- pro
| | |-- pro.pro
| | |-- pro.pro~
| | `-- util.o
| `-- util
| |-- calib_util.cpp
| `-- calib_util.h
|-- camera-calib.cpp
|-- camera-calib.h
|-- check_resources.h
|-- fatialfeaturedetect.cpp
|-- frontalization-models
| |-- DataAlign2LFWa.mat
| |-- eyemask.mat
| `-- model3Ddlib.mat
|-- frontalize.cpp
|-- frontalize.h
`-- main.cpp
我使用的Makefile文件是:
EXE = face_frontalization
OBJ_DIR = bin
CFLAGS = -g -w
dummy_build_folder := $(shell mkdir -p $(OBJ_DIR))
# c++ source files of the project
CXXFILES = $(shell find src -maxdepth 3 -type f -name '*.cpp')
CXXOBJ = $(patsubst src/%.cpp,bin/%.o,$(CXXFILES))
INCLUDE = -I/usr/include/dlib-18.18
LIBS = `pkg-config --libs opencv`
CXXFLAGS = `pkg-config --cflags opencv` -w -Wall -Wextra -g -std=c++0x
CFLAGS = `pkg-config --cflags opencv` -g -w
ifdef V
MUTE =
VTAG = -v
else
MUTE = @
endif
all: $(EXE)
# build successful
$(EXE): $(CXXOBJ)
$(CXX) $(CXXOBJ) -o $(EXE) $(LIBS)
$(OBJ_DIR)/%.o: src/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $< -c -o [email protected]
$(BUILD)
$(OBJ_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDE) $< -c -o [email protected]
run: all
./$(EXE)
clean:
# Cleaning...
-rm -f $(EXE) $(CXXOBJ)
rmdir bin/
現在我得到這個錯誤:
6 of 7
g++ `pkg-config --cflags opencv` -w -Wall -Wextra -g -std=c++0x -I/usr/include/dlib-18.18 src/calib/util/calib_util.cpp -c -o bin/calib/util/calib_util.o
Assembler messages:
Fatal error: can't create bin/calib/util/calib_util.o: No such file or directory
make: *** [bin/calib/util/calib_util.o] Error 1
我沒有得到這個錯誤之前,所以不知道爲什麼它來了。該文件存在於目錄中。我應該怎麼做呢?
我可以在Makefile中添加一些代碼,只需看到src文件夾結構就可以自動執行該代碼嗎? –
看[這裏](https://stackoverflow.com/questions/1950926/create-directories-using-make-file)。 – pushkin
只有1個問題。是使用這條線的好方法:CXXFILES = $(shell找到src -maxdepth 3 -type f -name'* .cpp') 還是有更好的方法來做到這一點嗎? –