How to Link .h in MakeFile

Hello Guys,

i have a Basler camera, where i grab images via pylon sdk.
I want to process the images via nvidia vpi, but i dont know
how i need to extend the makefile of the pylon sdk sample code,
in order to execute vpi functions

This is my current Makefile for my project:

# Makefile for Basler pylon sample program
.PHONY: all clean

# The program to build
NAME       := studienprojekt

# Installation directories for pylon
PYLON_ROOT ?= /opt/pylon

# Build tools and flags
LD         := $(CXX) # CXX entspricht g++
CPPFLAGS   := $(shell $(PYLON_ROOT)/bin/pylon-config --cflags)
CXXFLAGS   := -I/usr/include/opencv4
LDFLAGS    := $(shell  $(PYLON_ROOT)/bin/pylon-config --libs-rpath)
LDLIBS     := $(shell $(PYLON_ROOT)/bin/pylon-config --libs)

# Rules for building
all: $(NAME)

$(NAME): $(NAME).o
	$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)

$(NAME).o: $(NAME).cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<

clean:
	$(RM) $(NAME).o $(NAME)

I get an error, when i execute make with following error:
t.cpp:(.text+0xa0): undefined reference to `cv::imread()

I searched a bit and it seems like an linking problem, but how do
i extend my MakeFile to get it work?

Hi,

It looks like you need to add the OpenCV library like -lopencv_core -lopencv_imgcodecs.

For example, we can build the 01-convolve_2d sample with the below command.
You can change it into the Makefile correspondingly.

$ sudo g++ -o test main.cpp -I/usr/include/opencv4/ -L/opt/nvidia/vpi1/lib64/ -lopencv_core -lopencv_imgcodecs -lnvvpi

Thanks.