MinGw64 compiler bugged in 2018a ?

5 visualizaciones (últimos 30 días)
timo
timo el 28 de Mzo. de 2018
Comentada: Jean-Claude Arbaut el 9 de Abr. de 2018
I try to build a mex of a file who used lib c:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\x86_64-w64-mingw32\lib\libiphlpapi.a
When i use the mex command it looks for .lib files. But all the libraries are .a in the folder which i specified with -L . How to make linker to look for .a files ?
Here is the command:
mex -v -L"c:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\x86_64-w64-mingw32\lib" -llibiphlpapi.a 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 'libiphlpapi.a' specified with the -l option.
MEX looks for a file with one of the names:
liblibiphlpapi.a.lib
libiphlpapi.a.lib
Please specify the path to this library with the -L option.
Ps: it worked if i renamed the libiphlpapi.a to libiphlpapi.lib , but seems like a hack and not a proper solution . I think MSVC and MinGW operate differently w.r.t. expected extensions. While MSVC normally creates static libraries with a .lib extension, MinGW/MSYS respects the Unix defaults and requires a .a
  3 comentarios
Walter Roberson
Walter Roberson el 28 de Mzo. de 2018

Try

mex -v -L"c:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\x86_64-w64-mingw32\lib"    MACAddress_mex.c iphlpapi.a
timo
timo el 28 de Mzo. de 2018
Editada: Walter Roberson el 28 de Mzo. de 2018
OK the strange thing it solved itself after i did the next
1. switched he compiler to Visual Studio 2017 2. made the mex only with the mex -v -liphlpapi MACAddress_mex.c 3. restarted pc , ran mex-setup and selected MinGW for C
Now it works with MinGW . I even tested that it uses iphlpapi.a by deleting it from the compiler folder and seeing indeed that it cannot find the lib
Now the MinGW log looks also different than what it looked yesterday. WTF is going on lol ?
>> mex -v -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:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\atlmfc\include;C:\Program Files (x86)\Windows Kits\10\\include\10.0.16299.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.16299.0\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.16299.0\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.16299.0\winrt;C:\MATLAB\R2018a\extern\include;
Set LIB = C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\lib;;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.16299.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.16299.0\um\x64;C:\MATLAB\R2018a\lib\win64;
Set MW_TARGET_ARCH = win64;win64;
Set LIBPATH = C:\MATLAB\R2018a\extern\lib\win64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\atlmfc\lib\x64;
Options file details
-------------------------------------------------------------------
Compiler location: C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset
Options file: C:\Users\timo\AppData\Roaming\MathWorks\MATLAB\R2018a\mex_C_win64.xml
CMDLINE2 : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -m64 -Wl,--no-undefined -shared -static -s -Wl,"C:\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.obj C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj -liphlpapi -L"C:\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o MACAddress_mex.mexw64
CC : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc
COMPILER : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc
DEFINES : -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
CFLAGS : -fexceptions -fno-omit-frame-pointer
INCLUDE : -I"C:\MATLAB\R2018a/extern/include" -I"C:\MATLAB\R2018a/simulink/include" -I"C:\MATLAB\R2018a/extern\lib\win64\mingw64"
COPTIMFLAGS : -O -DNDEBUG
CDEBUGFLAGS : -g
LD : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc
LINKER : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc
LDTYPE : -shared -static
LDFLAGS : -m64 -Wl,--no-undefined
LINKEXPORT : -Wl,"C:\MATLAB\R2018a/extern/lib/win64/mingw64/mexFunction.def"
LINKEXPORTVER : -Wl,"C:\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def"
LIBLOC : C:\MATLAB\R2018a\extern\lib\win64\mingw64
LINKLIBS : -liphlpapi -L"C:\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas
LDOPTIMFLAGS : -s
LDDEBUGFLAGS : -g
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc
set CXXCOMPILER=C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\g++
set COMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set CXXCOMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -std=c++11 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set OPTIMFLAGS=-O -DNDEBUG
set DEBUGFLAGS=-g
set LINKER=C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc
set CXXLINKER=C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\g++
set LINKFLAGS=-m64 -Wl,--no-undefined -shared -static -liphlpapi -llibiphlpapi -L"C:\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -Wl,"C:\MATLAB\R2018a/extern/lib/win64/mingw64/mexFunction.def"
set LINKDEBUGFLAGS=-g
set NAME_OUTPUT=-o "%OUTDIR%%MEX_NAME%%MEX_EXT%"
MINGWROOT : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset
MATLABROOT : C:\MATLAB\R2018a
ARCH : win64
SRC : "C:\Users\timo\Desktop\Study\MATLAB\MACAddress_mex.c";"C:\MATLAB\R2018a\extern\version\c_mexapi_version.c"
OBJ : C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.obj;C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj
OBJS : C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.obj C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj
SRCROOT : C:\Users\timo\Desktop\Study\MATLAB\MACAddress_mex
DEF : C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.def
EXP : "MACAddress_mex.exp"
LIB : "MACAddress_mex.lib"
EXE : MACAddress_mex.mexw64
ILK : "MACAddress_mex.ilk"
MANIFEST : "MACAddress_mex.mexw64.manifest"
TEMPNAME : MACAddress_mex
EXEDIR :
EXENAME : MACAddress_mex
OPTIM : -O -DNDEBUG
LINKOPTIM : -s
CMDLINE1_0 : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\MATLAB\R2018a/extern/include" -I"C:\MATLAB\R2018a/simulink/include" -I"C:\MATLAB\R2018a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\Users\timo\Desktop\Study\MATLAB\MACAddress_mex.c" -o C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.obj
CMDLINE1_1 : C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\MATLAB\R2018a/extern/include" -I"C:\MATLAB\R2018a/simulink/include" -I"C:\MATLAB\R2018a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\MATLAB\R2018a\extern\version\c_mexapi_version.c" -o C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj
-------------------------------------------------------------------
Building with 'MinGW64 Compiler (C)'.
C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\MATLAB\R2018a/extern/include" -I"C:\MATLAB\R2018a/simulink/include" -I"C:\MATLAB\R2018a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\Users\timo\Desktop\Study\MATLAB\MACAddress_mex.c" -o C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.obj
C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\MATLAB\R2018a/extern/include" -I"C:\MATLAB\R2018a/simulink/include" -I"C:\MATLAB\R2018a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\MATLAB\R2018a\extern\version\c_mexapi_version.c" -o C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj
C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -m64 -Wl,--no-undefined -shared -static -s -Wl,"C:\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.obj C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj -liphlpapi -L"C:\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o MACAddress_mex.mexw64
Recompile embedded version with '-DMATLAB_MEXCMD_RELEASE=R2017b'
C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\MATLAB\R2018a/extern/include" -I"C:\MATLAB\R2018a/simulink/include" -I"C:\MATLAB\R2018a/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O -DNDEBUG "C:\MATLAB\R2018a\extern\version\c_mexapi_version.c" -o C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj -DMATLAB_MEXCMD_RELEASE=R2017b
C:\ProgramData\MATLAB\SupportPackages\R2018a_1\3P.instrset\mingw_w64.instrset\bin\gcc -m64 -Wl,--no-undefined -shared -static -s -Wl,"C:\MATLAB\R2018a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\MACAddress_mex.obj C:\Users\timo\AppData\Local\Temp\mex_2118226148433_10944\c_mexapi_version.obj -liphlpapi -L"C:\MATLAB\R2018a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o MACAddress_mex.mexw64
MEX completed successfully.

Iniciar sesión para comentar.

Respuesta aceptada

timo
timo el 28 de Mzo. de 2018
Editada: timo el 28 de Mzo. de 2018
Correction : The user have to give the path to the MinGW64 lib .a file even if its in the MinGW64 standard lib directory . Thats very user unfriendly and i reported this mex behaviour to the mingw64 developers
Here is the correct command (please note that for VS2017 compiler only -l libname is enough !)
mex -v c:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset\x86_64-w64-mingw32\lib\libiphlpapi.a MACAddress_mex.c
  8 comentarios
timo
timo el 7 de Abr. de 2018
Do you have to do this when you use visual studio 2015 /2017 compiler?
Jean-Claude Arbaut
Jean-Claude Arbaut el 9 de Abr. de 2018
Yes, but usually you do not see it. When you start Visual Studio's command line (not the IDE, but there are similar settings in the IDE), it runs vcvars64.bat or vcvars32.bat before you get to the command line.
These files are found in the VS installation directory, and they setup many environment variables needed by the compiler. You can see the list of environment variables by typing "set" in the console (some of them are set up by Windows, most come from vcvarsNN.bat).
Now, if for some reason the compiler does not find necessary include or library files, you can update the INCLUDE and LIB environment variables (or you can pass options to the compiler and/or linker directly).

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by