构建简要模块

Build brief module

本文关键字:模块 构建      更新时间:2023-10-16

我试图构建简短的软件。首先,我创建。/lib/libbrief。所以,其次,我试图建立主文件。.zip文件中包含的makefile:

CC=g++
SOURCES=main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=main
//#Only enable -msse4.2 on CPUs supporting the POPCNT instruction
CFLAGS = -Wall -DNDEBUG -O3 -march=nocona #-msse4.2 
//#CFLAGS = -Wall -DDEBUG -g -O0 -fno-inline-functions
LDFLAGS = -Wl
//# BRIEF
CFLAGS += -I../brief/include
LDFLAGS += -L../brief/lib -lbrief
//# OpenCV
CFLAGS += `pkg-config opencv --cflags`
LDFLAGS += `pkg-config opencv --libs`
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) -g -c $(CFLAGS) $< -o $@
 clean:
rm -f $(OBJECTS) $(EXECUTABLE) matches.png

然而,我得到错误,与opencv相关。发现的错误:

g++ -Wl -L../brief/lib -lbrief `pkg-config opencv --libs` main.o -o main
main.o: In function `~BRIEF':
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:203:     
undefined reference to `cvReleaseImage'
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:204:
undefined reference to `cvReleaseImage'
main.o: In function `BRIEF':
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:156:   
undefined reference to `cvCreateImage'
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:157:
undefined reference to `cvCreateImage'
main.o: In function `TestSampler<signed char>::sampleGaussian(signed char*, int, int)'
main.o: In function `BRIEF':
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:156: 
undefined reference to `cvCreateImage'
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:157: 
undefined reference to `cvCreateImage'
main.o: In function `TestSampler<signed char>::sampleGaussian(signed char*, int, int)':
main.o: In function `BRIEF::writeTests(std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&) const':
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:511: 
undefined reference to `utils::stdoutError(std::basic_string<char, 
std::char_traits<char>, 
std::allocator<char> >, char const*, int, char const*)'
main.o: In function `BRIEF::readTests(std::basic_string<char, std::char_traits<char>,  
std::allocator<char> > const&)':
Desktop/asdf/brief_v1.0/test_app/../brief/include/brief/BRIEF.hpp:524: 
undefined reference to `utils::stdoutError(std::basic_string<char,
std::char_traits<char>, 
std::allocator<char> >, char const*, int, char const*)'
main.o: In function `detectSURF':
Desktop/asdf/brief_v1.0/test_app/main.cpp:92: undefined reference to  
`cvCreateMemStorage'
Desktop/asdf/brief_v1.0/test_app/main.cpp:101: undefined reference to
`cvExtractSURF'
Desktop/asdf/brief_v1.0/test_app/main.cpp:106: undefined reference to    
`cvGetSeqElem'
main.o: In function `timeDescription(int)':
Desktop/asdf/brief_v1.0/test_app/main.cpp:201: undefined reference to
`cvLoadImage'
Desktop/asdf/brief_v1.0/test_app/main.cpp:214: undefined reference to 
`cvReleaseImage'
main.o: In function `~BRIEF':

如何构建合适的main.cpp?

您必须在之前列出链接上的所有对象文件,例如它们使用的库。

参见,例如,为什么库的链接顺序有时会导致GCC中的错误?