darknet yolo make error, lack of instance-segmenter.o rules

darknet yolo make error, lack of instance-segmenter.o rules

Error reason

Makefile does not recognize the compilation rules for instance-segmenter.o, but in fact instance-segmenter.cpp exists
darknet/examples
bold style

Solution

compile manually

  1. Manually compile and generate the output file instance-segmenter.o
g++ -Iinclude/ -Isrc/ -DGPU -I/usr/local/cuda/include/ -Wall -Wno-unused-result -Wno-unknown-pragmas -fPIC -fpermissive -Ofast -DGPU -c ./examples/instance_segmenter.cpp -o obj/instance_segmenter.o

Generated successfully
insert image description here

  1. Modify the Makefile to skip the automation process
    Since the Makefile is still obsessed with automatically generating instance-segmenter.o, in fact it has been manually generated, so modify the Makefile to
    insert image description here
    find the line in the above figure, delete instance-segmenter.o
    and continue making

new question

Due to the deletion of instance-segmenter.o, the final darknet generation will lack a dependency

error message

g++ -Iinclude/ -Isrc/ -DGPU -I/usr/local/cuda/include/ -Wall -Wno-unused-result -Wno-unknown-pragmas -fPIC -fpermissive -Ofast -DGPU obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/darknet.o libdarknet.a -o darknet -lm -pthread  -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -lstdc++  libdarknet.a
/usr/bin/ld: obj/darknet.o: in function `main':
darknet.cpp:(.text.startup+0x3af): undefined reference to `run_isegmenter(int, char**)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:75:darknet] 错误 1

Solution

Manually compile the last step

g++ -Iinclude/ -Isrc/ -DGPU -I/usr/local/cuda/include/ -Wall -Wno-unused-result -Wno-unknown-pragmas -fPIC -fpermissive -Ofast -DGPU obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/instance_segmenter.o obj/darknet.o libdarknet.a -o darknet -lm -pthread  -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -lstdc++  libdarknet.a

insert image description here
Generated successfullyinsert image description here

Replenish

g++ compile options

g++ is a tool in the GNU Compiler Collection for compiling C++ code. You can use different compile options to control the behavior of compilation. Here are some common g++ compilation options:

-o <output_file>: Specifies the name of the output file.
-Wall: Enable common warning messages.
-Werror: Treat warnings as errors, causing compilation to fail.
-std=: Specifies the C++ standard to use (for example: -std=c++11, -std=c++14, -std=c++17, etc.).
-I <include_path>: Add search path for include files.
-L <library_path>: Add the search path for library files.
-l: link specific library.
-g: Generate debug information for debugging.
-O: Optimization level, where can be 0, 1, 2, 3 or s.
-pthread: Link the POSIX thread library at compile time.
-f: Enable or disable specific compilation features, such as -finline-functions.
The following is an example compile command, using some common options:

g++ -o my_program my_program.cpp -std=c++11 -Wall -Werror -I /path/to/include -L /path/to/libs -lmylib -g -O2 -pthread

In this command, my_program.cpp is the source file you want to compile, -o my_program specifies that the output file name is my_program, -std=c++11 specifies to use the C++11 standard, -Wall -Werror enables warnings and Treated as an error, -I /path/to/include adds include file search path, -L /path/to/libs adds library file search path, -lmylib links library named mylib, -g generates debug information, -O2 enables Optimization level 2, -pthread Links the POSIX threads library.

Makefile compilation rules

Makefile is a file used to manage source code and build process. It describes the dependencies between source code files and how to compile and build the project. A typical Makefile contains compilation rules, dependencies, and build commands.

# 定义编译器和编译选项
CXX = g++
CXXFLAGS = -std=c++11 -Wall

# 定义目标文件和依赖关系
TARGET = my_program
SRCS = main.cpp foo.cpp bar.cpp
OBJS = $(SRCS:.cpp=.o)

# 默认目标
all: $(TARGET)

# 生成可执行文件
$(TARGET): $(OBJS)
	$(CXX) $(CXXFLAGS) -o $@ $(OBJS)

# 生成目标文件
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# 清理生成的文件
clean:
	rm -f $(OBJS) $(TARGET)

In this example, the Makefile contains the following sections:

Compiler CXX and compile options CXXFLAGS are defined.
Defines the target file name TARGET, the source file list SRCS, and the target file list OBJS.
all is the default target, which depends on $(TARGET).
The $(TARGET) target depends on the object file list $(OBJS) and produces an executable.
Generate object files using pattern rules, such as compiling .cpp files into .o object files.
The clean target is used to remove generated object files and executables.

Guess you like

Origin blog.csdn.net/qq_38853759/article/details/132516501