Why MEX cannot find library 'm' specified with the -l option?
25 views (last 30 days)
Show older comments
K M Ibrahim Khalilullah
on 11 Oct 2017
Commented: Walter Roberson
on 6 Aug 2020
I compiling some c files to make mex files in windows 10 64-bit operating system. but when I run it gives the following error:
Error using mex
MEX cannot find library 'm' specified with the -l option.
MEX looks for a file with one of the names:
m.lib
libm.lib
Please specify the path to this library with the -L option.
Error in make (line 17)
mex CC=g++ -lm get_full_speed.c
7 Comments
Soham Patel
on 18 Jun 2018
Edited: Walter Roberson
on 18 Jun 2018
mex -O -I/usr/include/opencv -lcxcore -lcv -lhighgui -c seeds2.cpp
mex -O mexSEEDS.cpp -I/usr/include/opencv -lcxcore -lcv -lhighgui seeds2.o
i am getting error in this file
MEX cannot find library 'cxcore' specified with the -l option.
MEX looks for a file with one of the names:
libcxcore.lib
cxcore.lib
Please specify the path to this library with the -L option.
can you help me to solved this error?
my opencv folder in c drive in download "C:\Users\Admin\Downloads\opencv"
can you help to write path of opencv?
Walter Roberson
on 18 Jun 2018
mex -O -I/usr/include/opencv -LC:/Users/Admin/Downloads/opencv -lcxcore -lcv -lhighgui -c seeds2.cpp
I suspect you will also need to change the -I/usr/include/opencv to something else, but where will depend on where the opencv include files got installed. possibly
mex -O -IC:/Users/Admin/Downloads/opencv/include -LC:/Users/Admin/Downloads/opencv -lcxcore -lcv -lhighgui -c seeds2.cpp
Accepted Answer
Walter Roberson
on 11 Oct 2017
I see a hint that libm might be built in for MinGW. Try without the -lm
2 Comments
Walter Roberson
on 6 Aug 2020
The original code was
mex CC=g++ -lm get_full_speed.c
instead you would use
mex CC=g++ get_full_speed.c
More Answers (1)
timo
on 28 Mar 2018
Edited: Walter Roberson
on 28 Mar 2018
I have a similar issue . Didnt help not to use -l
>> mex -v -L"c:\MATLAB\R2018a\extern\lib\win64\mingw64" -liphlpapi MACAddress_mex.c
Verbose mode is on.
... Looking for compiler 'MinGW64 Compiler (C)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset').
... Looking for file 'C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc.exe' ...Yes.
... Looking for folder 'C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset' ...Yes.
Found installed compiler 'MinGW64 Compiler (C)'.
Set PATH = C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin;C:\MATLAB\R2018a\extern\include\win64;C:\MATLAB\R2018a\extern\include;C:\MATLAB\R2018a\simulink\include;C:\MATLAB\R2018a\lib\win64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\TDM-GCC-64\bin;C:\MATLAB\R2018a\bin;C:\Users\timo\AppData\Local\Microsoft\WindowsApps;c:\SysGCC\mingw64\bin;
Set INCLUDE = C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\include;;C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\include;;
Set LIB = C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\lib;;C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\lib;;
Set MW_TARGET_ARCH = win64;win64;
Set LIBPATH = C:\MATLAB\R2018a\extern\lib\win64;C:\MATLAB\R2018a\extern\lib\win64;
Error using mex
MEX cannot find library 'iphlpapi' specified with the -l option.
MEX looks for a file with one of the names:
libiphlpapi.lib
iphlpapi.lib
Please specify the path to this library with the -L option.
1 Comment
Walter Roberson
on 28 Mar 2018
You should be using the order
mex -v -L"c:\MATLAB\R2018a\extern\lib\win64\mingw64" MACAddress_mex.c -liphlpapi
However, I am not sure where you would find a MinGW compatible iphlpapi.lib . I see that it is normally provided with VS SDK
has iphlpapi.a . I am not sure if that implies that you would have that file in the directory that you -L'd . If so then
mex -v -L"c:\MATLAB\R2018a\extern\lib\win64\mingw64" MACAddress_mex.c iphlpapi.a
See Also
Categories
Find more on MATLAB Support for MinGW-w64 C/C++ Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!