when "libopencv_world440.dll.a" copied to matlab's current working directory,then I was able to pass and run the Mex file successfully without specifying "-l", the reference example is as follows:
% Notice: first use "mex -setup" to choose your c/c++ compiler
clear;
%% -------------------------------------------------------------------
%% get the architecture of this computer
is_64bit = strcmp(computer,'MACI64') || strcmp(computer,'GLNXA64') || strcmp(computer,'PCWIN64');
%% -------------------------------------------------------------------
%% the configuration of compiler
% You need to modify this configuration according to your own path of OpenCV
% 注意:你的VS/MinGW64 OpenCV平台一定要匹配Matlab 64位的!
out_dir='./';% 当前目录
CPPFLAGS = ' -g -ID:\opencv_4_4_0\MinGW64_v8_OpenCV4_4_Contrib_install\include -ID:\opencv_4_4_0\MinGW64_v8_OpenCV4_4_Contrib_install\include\opencv2'; % your OpenCV "include" path
LDFLAGS = ' -LD:\opencv_4_4_0\MinGW64_v8_OpenCV4_4_Contrib_install\x64\mingw\lib'; % 用OpenCV release版本的"lib"路径
% LIBS = ' -lopencv_world440'; % msvc release版本的lib,无后缀,系统会自动加上去
LIBS = ' libopencv_world440.dll.a'; % mingw64 编译器.a库文件,无"-l"参数
if is_64bit
CPPFLAGS = [CPPFLAGS ' -largeArrayDims'];
end
%% add your files here!
compile_files = [
% the list of your code files which need to be compiled
' D:\vs_files\project1\project1\findCheckerBoarderCorners.cpp'
];
%-------------------------------------------------------------------
%% compiling...
str = compile_files;
fprintf('compilation of: %s\n', str);
str = [str ' -outdir ' out_dir CPPFLAGS LDFLAGS LIBS];
args = regexp(str, '\s+', 'split');
mex(args{:});
fprintf('Congratulations, compilation successful!!!\n');