gpt4 book ai didi

c++ - 无法使用 makefile 编译

转载 作者:行者123 更新时间:2023-11-30 05:27:36 25 4
gpt4 key购买 nike

我在 ubuntu 上有一些 opencv c++ 代码,其文件夹结构是:

|-- 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 $@
$(BUILD)

$(OBJ_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDE) $< -c -o $@

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

我以前没有遇到过这个错误,所以不知道为什么会出现。该文件存在于目录中。我该怎么办?

最佳答案

看起来你的目录结构有点不对。

can't create bin/calib/util/calib_util.o: No such file or directory

根据您的层次结构,bin 下没有目录calib/util。尝试创建它并再次运行 make

关于c++ - 无法使用 makefile 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37199784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com