Why MEX cannot find library 'm' specified with the -l option?

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 commentaires

I see a hint that libm might be built in for MinGW
mex CC=g++ get_full_speed.c -lm
in the sense that it says that -l libraries need to go after the objects that reference them.
Thanks. still has this problem:
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++ get_full_speed.c -lm
Try without the -lm at all
Thanks, it is ok without using -lm.
@Walter Roberson How can I accept your answer?
Soham Patel
Soham Patel le 18 Juin 2018
Modifié(e) : Walter Roberson le 18 Juin 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?
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

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 11 Oct 2017
I see a hint that libm might be built in for MinGW. Try without the -lm

2 commentaires

How to achieve this?
The original code was
mex CC=g++ -lm get_full_speed.c
instead you would use
mex CC=g++ get_full_speed.c

Connectez-vous pour commenter.

Plus de réponses (1)

timo
timo le 28 Mar 2018
Modifié(e) : Walter Roberson le 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 commentaire

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by