gpt4 book ai didi

c++ - 用于链接 OpenCV 和现有库的 Makefile(不使用 cmake)

转载 作者:行者123 更新时间:2023-12-03 12:49:02 32 4
gpt4 key购买 nike

目前,我正在研究如何使用 Makefile 将现有库与 OpenCV 链接。我对 Makefile 还很陌生。我在互联网上搜索过,但大多数答案是在 CMake 上。即使有答案,结果的输出也包含错误。请看一下我的 Makefile,我做错了什么吗?

生成文件

###############################################################
#
# Purpose: Makefile for "head_tracking"
# Author.: robotis
# Version: 0.1
# License: GPL
#
###############################################################

TARGET = head_tracking

INCLUDE_DIRS = -I../../../include -I../../../../Framework/include

CXX = g++
CXXFLAGS += -O2 -DLINUX -Wall $(INCLUDE_DIRS)
#CXXFLAGS += -O2 -DDEBUG -DLINUX -Wall $(INCLUDE_DIRS)
LFLAGS += -lpthread -ljpeg -lrt
CPPFLAGS = $(shell pkg-config --cflags opencv2) #The one i added
LDLIBS = $(shell pkg-config --libs opencv2) #The one i addded

OBJECTS = main.o

all: $(TARGET)

clean:
rm -f *.a *.o $(TARGET) core *~ *.so *.lo

libclean:
make -C ../../../build clean

distclean: clean libclean

darwin.a:
make -C ../../../build

$(TARGET): darwin.a $(OBJECTS)
$(CXX) $(CFLAGS) $(OBJECTS) ../../../lib/darwin.a -o $(TARGET) $(LFLAGS)
chmod 755 $(TARGET)

# useful to make a backup "make tgz"
tgz: clean
mkdir -p backups
tar czvf ./backups/head_tracking_`date +"%Y_%m_%d_%H.%M.%S"`.tgz --exclude backups *

Error Image: Undefined Refrenced

最佳答案

好吧,我终于解决了我的链接错误。我现在可以使用我的 Robotis-Op 库编译 openCV。这是新的 Makefile。

###############################################################
#
# Purpose: Makefile for "head_tracking"
# Author.: robotis
# Version: 0.1
# License: GPL
#
###############################################################

TARGET = head_tracking

INCLUDE_DIRS = -I../../../include -I../../../../Framework/include -I/usr/local/include/opencv2

CXX = g++
CXXFLAGS += -O2 -DLINUX -Wall $(INCLUDE_DIRS) `pkg-config --cflags opencv`
#CXXFLAGS += -O2 -DDEBUG -DLINUX -Wall $(INCLUDE_DIRS)
LFLAGS += -lpthread -ljpeg -lrt
LDFLAGS = `pkg-config --libs opencv`
#CPPFLAGS = $(shell pkg-config --cflags opencv2)
#LDLIBS = $(shell pkg-config --libs opencv2)

OBJECTS = main.o

all: $(TARGET)

clean:
rm -f *.a *.o $(TARGET) core *~ *.so *.lo

libclean:
make -C ../../../build clean

distclean: clean libclean

darwin.a:
make -C ../../../build

$(TARGET): darwin.a $(OBJECTS)
$(CXX) $(CFLAGS) $(OBJECTS) ../../../lib/darwin.a -o $(TARGET) $(LFLAGS) $(LDFLAGS)
chmod 755 $(TARGET)

# useful to make a backup "make tgz"
tgz: clean
mkdir -p backups
tar czvf ./backups/head_tracking_`date +"%Y_%m_%d_%H.%M.%S"`.tgz --exclude back

ups *

关于c++ - 用于链接 OpenCV 和现有库的 Makefile(不使用 cmake),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48054566/

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