How do I compile a MEX file using Armadillo?
Mostrar comentarios más antiguos
I am trying to compile a MEX file using C++ code which uses the Armadillo C++ library. Armadillo depends on BLAS and LAPACK, both of which ship with MATLAB. Linking against custom copies of libraries is not a supported workflow, so instead I am linking against the versions within MATLAB using a "mex" command like:
>> mex(..., ['-L' matlabroot '\extern\lib\win64\mingw64'], '-llapack', '-lblas')
Or, if using the MSVC C++ compiler rather than MinGW:
>> mex(..., ['-L' matlabroot '\extern\lib\win64\microsoft'], '-llapack', '-lblas')
Running these gives outputs a large number of errors, all of the same pattern:
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x113f8): undefined reference to `dgemv_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x11ba5): undefined reference to `dnrm2_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x13fc9): undefined reference to `dgemv_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x160a7): undefined reference to `dgemv_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x2f7a0): undefined reference to `ddot_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x3efe6): undefined reference to `dgemv_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x3f61a): undefined reference to `dgemv_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x44831): undefined reference to `dgemv_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x44add): undefined reference to `dgemm_'
%USER%\Local\Temp\mex_10327564389625623_6476\UCompC.obj:UCompC.cpp:(.text+0x44c84): undefined reference to `dgemv_'
...
All of these are functions in BLAS and LAPACK which are referenced by Armadillo.
How do I get Armadillo to compile? I am using MATLAB release R2022a.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!