0
votes

I am facing a problem while trying to link opencv to CPP project generated by Matlab Coder. In the auto generated Makefile of the project, I added pkg-config --cflags opencv to CFLAGS and pkg-config --libs opencv to LIBS (opencv 3.4), which then gives the error "No rule to make target '-L/usr/local/lib'". Any ideas how to fix ther error?

PRODUCT_NAME              = runeef
MAKEFILE                  = runeef_rtw.mk
MATLAB_ROOT               = /usr/local/Polyspace/R2020a
MATLAB_BIN                = /usr/local/Polyspace/R2020a/bin
MATLAB_ARCH_BIN           = $(MATLAB_BIN)/glnxa64
MASTER_ANCHOR_DIR         = 
START_DIR                 = /home/dell/Documents/purefusion/codegen/exe/runeef
TGT_FCN_LIB               = ISO_C++11
SOLVER_OBJ                = 
CLASSIC_INTERFACE         = 0
MODEL_HAS_DYNAMICALLY_LOADED_SFCNS = 
RELATIVE_PATH_TO_ANCHOR   = .
C_STANDARD_OPTS           = -fwrapv -ansi -pedantic -Wno-long-long
CPP_STANDARD_OPTS         = -fwrapv -std=c++11 -pedantic

###########################################################################
## TOOLCHAIN SPECIFICATIONS
###########################################################################

# Toolchain Name:          GNU gcc/g++ | gmake (64-bit Linux)
# Supported Version(s):    
# ToolchainInfo Version:   2020a
# Specification Revision:  1.0
# 
#-------------------------------------------
# Macros assumed to be defined elsewhere
#-------------------------------------------

# C_STANDARD_OPTS
# CPP_STANDARD_OPTS

#-----------
# MACROS
#-----------

WARN_FLAGS         = -Wall -W -Wwrite-strings -Winline -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Wcast-align
WARN_FLAGS_MAX     = $(WARN_FLAGS) -Wcast-qual -Wshadow
CPP_WARN_FLAGS     = -Wall -W -Wwrite-strings -Winline -Wpointer-arith -Wcast-align
CPP_WARN_FLAGS_MAX = $(CPP_WARN_FLAGS) -Wcast-qual -Wshadow

TOOLCHAIN_SRCS = 
TOOLCHAIN_INCS = 
TOOLCHAIN_LIBS = 

#------------------------
# BUILD TOOL COMMANDS
#------------------------

# C Compiler: GNU C Compiler
CC = gcc

# Linker: GNU Linker
LD = g++

# C++ Compiler: GNU C++ Compiler
CPP = g++

# C++ Linker: GNU C++ Linker
CPP_LD = g++

# Archiver: GNU Archiver
AR = ar

# MEX Tool: MEX Tool
MEX_PATH = $(MATLAB_ARCH_BIN)
MEX = "$(MEX_PATH)/mex"

# Download: Download
DOWNLOAD =

# Execute: Execute
EXECUTE = $(PRODUCT)

# Builder: GMAKE Utility
MAKE_PATH = %MATLAB%/bin/glnxa64
MAKE = "$(MAKE_PATH)/gmake"


#-------------------------
# Directives/Utilities
#-------------------------

CDEBUG              = -g
C_OUTPUT_FLAG       = -o
LDDEBUG             = -g
OUTPUT_FLAG         = -o
CPPDEBUG            = -g
CPP_OUTPUT_FLAG     = -o
CPPLDDEBUG          = -g
OUTPUT_FLAG         = -o
ARDEBUG             =
STATICLIB_OUTPUT_FLAG =
MEX_DEBUG           = -g
RM                  = @rm -f
ECHO                = @echo
MV                  = @mv
RUN                 =

#--------------------------------------
# "Faster Runs" Build Configuration
#--------------------------------------

ARFLAGS              = ruvs
CFLAGS               = $(shell pkg-config --cflags opencv) -c $(C_STANDARD_OPTS)  -fPIC \
                       -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations
CPPFLAGS             = $(shell pkg-config --cflags opencv) -c $(CPP_STANDARD_OPTS) -fPIC \
                       -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations
CPP_LDFLAGS          = -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)"
CPP_SHAREDLIB_LDFLAGS  = -shared -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" -Wl,--no-undefined
DOWNLOAD_FLAGS       =
EXECUTE_FLAGS        =
LDFLAGS              = -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)"
MEX_CPPFLAGS         =
MEX_CPPLDFLAGS       =
MEX_CFLAGS           =
MEX_LDFLAGS          =
MAKE_FLAGS           = -f $(MAKEFILE)
SHAREDLIB_LDFLAGS    = -shared -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" -Wl,--no-undefined



###########################################################################
## OUTPUT INFO
###########################################################################

PRODUCT = /home/dell/Documents/purefusion/runeef
PRODUCT_TYPE = "executable"
BUILD_TYPE = "Executable"

###########################################################################
## INCLUDE PATHS
###########################################################################

INCLUDES_BUILDINFO = -I$(START_DIR) -I/home/dell/Documents/purefusion -I$(MATLAB_ROOT)/extern/include -I$(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/include -I$(MATLAB_ROOT)/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe 

INCLUDES = $(INCLUDES_BUILDINFO)

###########################################################################
## DEFINES
###########################################################################

DEFINES_CUSTOM = 
DEFINES_STANDARD = -DMODEL=runeef

DEFINES = $(DEFINES_CUSTOM) $(DEFINES_STANDARD)

###########################################################################
## SOURCE FILES
###########################################################################

SRCS = $(START_DIR)/rt_nonfinite.cpp $(START_DIR)/rtGetNaN.cpp $(START_DIR)/rtGetInf.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/detectFASTCore.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/cgCommon.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/extractFreakCore.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/mwfreak.cpp /home/dell/Documents/purefusion/codegen/exe/main.cpp $(START_DIR)/runeef_rtwutil.cpp $(START_DIR)/runeef_data.cpp $(START_DIR)/runeef_initialize.cpp $(START_DIR)/runeef_terminate.cpp $(START_DIR)/runeef.cpp $(START_DIR)/colon.cpp $(START_DIR)/string1.cpp $(START_DIR)/rgb2gray.cpp $(START_DIR)/abs.cpp $(START_DIR)/histeq.cpp $(START_DIR)/minOrMax.cpp $(START_DIR)/sum.cpp $(START_DIR)/imhist.cpp $(START_DIR)/bsxfun.cpp $(START_DIR)/cornerPoints_cg.cpp $(START_DIR)/FeaturePointsImpl.cpp $(START_DIR)/repmat.cpp $(START_DIR)/extractFeatures.cpp $(START_DIR)/mod.cpp $(START_DIR)/eef.cpp $(START_DIR)/remapFun.cpp $(START_DIR)/prod.cpp $(START_DIR)/imfilter.cpp $(START_DIR)/padarray.cpp $(START_DIR)/multiscaleBlendingColor.cpp $(START_DIR)/gaussian_pyramid.cpp $(START_DIR)/laplacian_pyramid.cpp $(START_DIR)/upsample.cpp $(START_DIR)/reconstruct_laplacian_pyramid.cpp $(START_DIR)/robustNormalization.cpp $(START_DIR)/sort.cpp $(START_DIR)/sortIdx.cpp

ALL_SRCS = $(SRCS)

###########################################################################
## OBJECTS
###########################################################################

OBJS = rt_nonfinite.o rtGetNaN.o rtGetInf.o detectFASTCore.o cgCommon.o extractFreakCore.o mwfreak.o main.o runeef_rtwutil.o runeef_data.o runeef_initialize.o runeef_terminate.o runeef.o colon.o string1.o rgb2gray.o abs.o histeq.o minOrMax.o sum.o imhist.o bsxfun.o cornerPoints_cg.o FeaturePointsImpl.o repmat.o extractFeatures.o mod.o eef.o remapFun.o prod.o imfilter.o padarray.o multiscaleBlendingColor.o gaussian_pyramid.o laplacian_pyramid.o upsample.o reconstruct_laplacian_pyramid.o robustNormalization.o sort.o sortIdx.o

ALL_OBJS = $(OBJS)

###########################################################################
## PREBUILT OBJECT FILES
###########################################################################

PREBUILT_OBJS = 

###########################################################################
## LIBRARIES
###########################################################################

LIBS = $(MATLAB_ROOT)/bin/glnxa64/libmwjpegreader.so $(MATLAB_ROOT)/bin/glnxa64/libopencv_calib3d.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_core.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_features2d.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_flann.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_imgproc.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_ml.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_objdetect.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_video.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaarithm.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudabgsegm.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudafeatures2d.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudafilters.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaimgproc.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudalegacy.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaobjdetect.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaoptflow.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudastereo.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudawarping.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudev.so.3.4 $(shell pkg-config --libs opencv)
#/usr/local/lib/libopencv_core.so.4.5.1 /usr/local/lib/libopencv_imgcodecs.so.4.5.1 /usr/local/lib/libopencv_highgui.so.4.5.1

###########################################################################
## SYSTEM LIBRARIES
###########################################################################

SYSTEM_LIBS =  -L"$(MATLAB_ROOT)/bin/glnxa64" -lmwrgb2gray_tbb -lmwgetnumcores -lmwtbbhist -lmwgrayxform_tbb -lmwgrayto8 -lmwippfilter -lmwipp -lmwimfilter -lmwnhood -lm -lstdc++ 

###########################################################################
## ADDITIONAL TOOLCHAIN FLAGS
###########################################################################

#---------------
# C Compiler
#---------------

CFLAGS_ = -Wno-variadic-macros -Wno-variadic-macros
CFLAGS_BASIC = $(DEFINES) $(INCLUDES)

CFLAGS += $(CFLAGS_) $(CFLAGS_BASIC) 

#-----------------
# C++ Compiler
#-----------------

CPPFLAGS_ = -Wno-variadic-macros -Wno-variadic-macros
CPPFLAGS_BASIC = $(DEFINES) $(INCLUDES)

CPPFLAGS += $(CPPFLAGS_) $(CPPFLAGS_BASIC)

###########################################################################
## INLINED COMMANDS
###########################################################################

###########################################################################
## PHONY TARGETS
###########################################################################

.PHONY : all build buildobj clean info prebuild download execute


all : build
    @echo "### Successfully generated all binary outputs."


build : prebuild $(PRODUCT)


buildobj : prebuild $(OBJS) $(PREBUILT_OBJS) $(LIBS) 
    @echo "### Successfully generated all binary outputs."


prebuild : 


download : $(PRODUCT)


execute : download
    @echo "### Invoking postbuild tool "Execute" ..."
    $(EXECUTE) $(EXECUTE_FLAGS)
    @echo "### Done invoking postbuild tool."


###########################################################################
## FINAL TARGET
###########################################################################

#-------------------------------------------
# Create a standalone executable            
#-------------------------------------------

$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) $(LIBS)
    @echo "### Creating standalone executable "$(PRODUCT)" ..."
    $(CPP_LD) $(CPP_LDFLAGS) -o $(PRODUCT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group $(SYSTEM_LIBS) $(TOOLCHAIN_LIBS) 
    @echo "### Created: $(PRODUCT)"


###########################################################################
## INTERMEDIATE TARGETS
###########################################################################

#---------------------
# SOURCE-TO-OBJECT
#---------------------

%.o : %.c
    $(CC) $(CFLAGS) -o "$@" "$<"


%.o : %.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.c
    $(CC) $(CFLAGS) -o "$@" "$<"


%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


%.o : $(START_DIR)/%.c
    $(CC) $(CFLAGS) -o "$@" "$<"


%.o : $(START_DIR)/%.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


%.o : /home/dell/Documents/purefusion/%.c
    $(CC) $(CFLAGS) -o "$@" "$<"


%.o : /home/dell/Documents/purefusion/%.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


%.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/%.c
    $(CC) $(CFLAGS) -o "$@" "$<"


%.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/%.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


%.o : /home/dell/Documents/purefusion/codegen/exe/%.c
    $(CC) $(CFLAGS) -o "$@" "$<"


%.o : /home/dell/Documents/purefusion/codegen/exe/%.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


rt_nonfinite.o : $(START_DIR)/rt_nonfinite.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


rtGetNaN.o : $(START_DIR)/rtGetNaN.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


rtGetInf.o : $(START_DIR)/rtGetInf.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


detectFASTCore.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/detectFASTCore.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


cgCommon.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/cgCommon.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


extractFreakCore.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/extractFreakCore.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


mwfreak.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/mwfreak.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


main.o : /home/dell/Documents/purefusion/codegen/exe/main.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


runeef_rtwutil.o : $(START_DIR)/runeef_rtwutil.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


runeef_data.o : $(START_DIR)/runeef_data.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


runeef_initialize.o : $(START_DIR)/runeef_initialize.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


runeef_terminate.o : $(START_DIR)/runeef_terminate.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


runeef.o : $(START_DIR)/runeef.cpp
    $(CPP) $(CPPFLAGS)  -o "$@" "$<"


colon.o : $(START_DIR)/colon.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"

string1.o : $(START_DIR)/string1.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


rgb2gray.o : $(START_DIR)/rgb2gray.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


abs.o : $(START_DIR)/abs.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


histeq.o : $(START_DIR)/histeq.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


minOrMax.o : $(START_DIR)/minOrMax.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


sum.o : $(START_DIR)/sum.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


imhist.o : $(START_DIR)/imhist.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


bsxfun.o : $(START_DIR)/bsxfun.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


cornerPoints_cg.o : $(START_DIR)/cornerPoints_cg.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


FeaturePointsImpl.o : $(START_DIR)/FeaturePointsImpl.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


repmat.o : $(START_DIR)/repmat.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


extractFeatures.o : $(START_DIR)/extractFeatures.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


mod.o : $(START_DIR)/mod.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


eef.o : $(START_DIR)/eef.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


remapFun.o : $(START_DIR)/remapFun.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


prod.o : $(START_DIR)/prod.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


imfilter.o : $(START_DIR)/imfilter.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


padarray.o : $(START_DIR)/padarray.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


multiscaleBlendingColor.o : $(START_DIR)/multiscaleBlendingColor.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


gaussian_pyramid.o : $(START_DIR)/gaussian_pyramid.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


laplacian_pyramid.o : $(START_DIR)/laplacian_pyramid.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


upsample.o : $(START_DIR)/upsample.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


reconstruct_laplacian_pyramid.o : $(START_DIR)/reconstruct_laplacian_pyramid.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


robustNormalization.o : $(START_DIR)/robustNormalization.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


sort.o : $(START_DIR)/sort.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


sortIdx.o : $(START_DIR)/sortIdx.cpp
    $(CPP) $(CPPFLAGS) -o "$@" "$<"


###########################################################################
## DEPENDENCIES
###########################################################################

$(ALL_OBJS) : rtw_proj.tmw $(MAKEFILE)


clean : 
    $(ECHO) "### Deleting all derived files..."
    $(RM) $(PRODUCT)
    $(RM) $(ALL_OBJS)
    $(ECHO) "### Deleted all derived files."

And a part of the corresponding messages after make command.

g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros  -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe  -o "reconstruct_laplacian_pyramid.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/reconstruct_laplacian_pyramid.cpp"
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros  -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe  -o "robustNormalization.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/robustNormalization.cpp"
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros  -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe  -o "sort.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/sort.cpp"
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros  -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe  -o "sortIdx.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/sortIdx.cpp"
make: *** No rule to make target '-L/usr/local/lib', needed by '/home/dell/Documents/purefusion/runeef'.  Stop.

Also, the error message when I am removing $LIBS from

$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) $(LIBS)
    @echo "### Creating standalone executable "$(PRODUCT)" ..."
    $(CPP_LD) $(CPP_LDFLAGS) -o $(PRODUCT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group $(SYSTEM_LIBS) $(TOOLCHAIN_LIBS) 
    @echo "### Created: $(PRODUCT)"

Last few lines of messages

g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros  -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe  -o "sortIdx.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/sortIdx.cpp"
### Creating standalone executable /home/dell/Documents/purefusion/runeef ...
g++ -Wl,-rpath,"/usr/local/Polyspace/R2020a/bin/glnxa64",-L"/usr/local/Polyspace/R2020a/bin/glnxa64" -o /home/dell/Documents/purefusion/runeef rt_nonfinite.o rtGetNaN.o rtGetInf.o detectFASTCore.o cgCommon.o extractFreakCore.o mwfreak.o main.o runeef_rtwutil.o runeef_data.o runeef_initialize.o runeef_terminate.o runeef.o colon.o string1.o rgb2gray.o abs.o histeq.o minOrMax.o sum.o imhist.o bsxfun.o cornerPoints_cg.o FeaturePointsImpl.o repmat.o extractFeatures.o mod.o eef.o remapFun.o prod.o imfilter.o padarray.o multiscaleBlendingColor.o gaussian_pyramid.o laplacian_pyramid.o upsample.o reconstruct_laplacian_pyramid.o robustNormalization.o sort.o sortIdx.o -Wl,--start-group /usr/local/Polyspace/R2020a/bin/glnxa64/libmwjpegreader.so /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_calib3d.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_core.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_features2d.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_flann.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_imgproc.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_ml.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_objdetect.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_video.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaarithm.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudabgsegm.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudafeatures2d.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudafilters.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaimgproc.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudalegacy.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaobjdetect.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaoptflow.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudastereo.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudawarping.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudev.so.3.4 -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_highgui -lopencv_videoio -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -Wl,--end-group -L"/usr/local/Polyspace/R2020a/bin/glnxa64" -lmwrgb2gray_tbb -lmwgetnumcores -lmwtbbhist -lmwgrayxform_tbb -lmwgrayto8 -lmwippfilter -lmwipp -lmwimfilter -lmwnhood -lm -lstdc++   
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::Mat::Mat()'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_auto(int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::Mat::Mat(int, int, int)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_MatType(int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_MatType(int, int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_MatDepth(int, int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_auto(int, int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::Mat::total() const'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_auto(unsigned long, unsigned long, cv::detail::CheckContext const&)'
collect2: error: ld returned 1 exit status
make: *** [runeef_rtw.mk:270: /home/dell/Documents/purefusion/runeef] Error 1
1
Can you show the makefile? From the error text I'm guessing one or more variables being used in the compilation command expands to an empty string leading the compiler to think some other token in the command is actually the desired output target.G.M.
There's no way to know given the information you've provided. You'll have to show what you did: the value of CFLAGS, the rules it's used, etc.MadScientist
I updated the question adding the link to makefile.Suzy
Note that your makefile should be included as formatted text in the question, not referred to via a link that requires downloading.G.M.

1 Answers

1
votes

Your makefile has the variable assignment (edited for brevity)...

LIBS = $(MATLAB_ROOT)/bin/glnxa64/libmwjpegreader.so ... $(shell pkg-config --libs opencv)

Where the $(shell pkg-config --libs opencv) component will expand to something like...

-L/usr/local/lib -lopencv

But you then use $(LIBS) as a dependency for several targets, e.g...

$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) $(LIBS)

which expands to (again, edited for brevity)...

$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) -L/usr/local/lib -lopencv

Hence, when make attempts to process the target $(PRODUCT) it will see that the target seemingly depends on -L/usr/local/lib and act accordingly.

It's difficult to provide a more complete answer without more context but $(LIBS) probably shouldn't be listed as a dependency for this or any other targets.