Borrar filtros
Borrar filtros

.bat file wont create .mexw64 to use a C++ code in Matlab?

2 visualizaciones (últimos 30 días)
sebastian bugna
sebastian bugna el 14 de Ag. de 2015
Comentada: Jian Kang el 10 de Mzo. de 2016
Hi,
I'm trying to use the next downloadable code for a school project which Im writing in Matlab:
It comes with some C++ sourcecodes, and a "build_windows.bat" to make the mex files. *Im using windows with Matlab R2014b.
I'm new to compile mex files at all.
As far as I understood in the readme, and reading the .bat file: the bat file will compile and create a .mexw64 file that when Matlab call the funcion "nnmex.m", instead of calling the function nnmex from nnmex.m it will give priority to nnmex.mexw64 file.
But after so many tries I still cant create those .mex64file, and dont even know if what im doing has sense at all.
I tried executing .bat file from cmd line in windows, but it says: "mex: invalid command line"
I also wrote in matlab " mex -setup C++" , have the SDK 7.1 compiler. but it brought out more compiling error, i guess that they have to do with dependencies issues.
I guess this must be really simple but I dont know how to build de the mex files out of the .bat file in windows.
Please, I would be really greatfull if you could provide me with some help. Thanks.
Here-s a little more information about these files
The readme says:
Build: Use build_windows.bat / build_mac.sh / build_unix.sh for your system
(Known to work on Windows XP, Vista, Mac OS X, and Linux, after varying amounts of fighting with the compiler).
(Disable optimizations if you're just trying to get it to build, this will help speed up your build process).
(OpenMP is used, but not required -- set USE_OPENMP in nn.h to 0 if your compiler does not support OpenMP)
Usage: do 'help nnmex' or 'help votemex' in MATLAB, or run test_mex.m, test_rot_scale.m, test_descriptor_mex.m, or test_knn.m._
The .bat files contains this:
@rem It works without /nodefaultlib:libcmt.lib
@rem Unoptimized (fast to build)
call mex OPTIMFLAGS="/DNDEBUG /DMEX_MODE /openmp" -inline knn.cpp mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex
call mex OPTIMFLAGS="/DNDEBUG /DMEX_MODE /openmp" -inline knn.cpp mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output votemex

Respuestas (1)

nicokla
nicokla el 31 de Ag. de 2015
Editada: Walter Roberson el 31 de Ag. de 2015
Hi,
I had the same problem and I figured out how to use mex : From matlab command line, you do
mex OPTIMFLAGS="/DNDEBUG /DMEX_MODE /openmp" knn.cpp mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex
and
mex OPTIMFLAGS="/DNDEBUG /DMEX_MODE /openmp" knn.cpp mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output votemex
If you want a more optimized version of the mex, you use :
mex OPTIMFLAGS="/Ox /Oi /Oy /DNDEBUG /fp:fast /arch:SSE2 /DMEX_MODE /openmp" mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp knn.cpp -output nnmex
and
mex OPTIMFLAGS="/Ox /Oi /Oy /DNDEBUG /fp:fast /DMEX_MODE /openmp" mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp knn.cpp -output votemex
In fact I simply removed the -inline and call words which are probably only useful when it's used from a bat file.
Also I think it can also be solved by calling the bat from a Visual Studio prompt instead of from cmd.exe, but I have not checked.
Hope it helped
Nicolas
  1 comentario
Jian Kang
Jian Kang el 10 de Mzo. de 2016
Which compiler did you use? I use MS VS++2013 compiler in matlab2015b in wincows10. But there is compiling errors. I took days to mex this code. Thank you very much.

Iniciar sesión para comentar.

Categorías

Más información sobre Code Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by