MinGW clibgen build fails to find -llibMatlabDataArray
Show older comments
I am using Matlab2021a. I am trying to wrap an existing C++ library for use in Matlab. I did the wrapping in Linux and I am now trying to do the same thing in Windows. For my comiler, I am using MinGW 6.3.0 as installed by the using the download provided by Mathworks:
https://www.mathworks.com/matlabcentral/fileexchange/52848-matlab-support-for-mingw-w64-c-c-compiler
I was able to run the clibgen.generateLibraryDefinition command, but when I try to do a build, I get linker errors. To narrow down the origin of the problem, I followed a useful simple example case. The instructions are provided at the following link:
I made the libfive.h and libfive.cpp files as per those instructions. I then built a shared library using MinGW's g++.
$ g++ -c -fPIC libfive.cpp -o libfive.o
$ g++ libffive.o -shared -o libfive_win.so
From inside Matlab, I generated a library definition.
>> clibgen.generateLibraryDefinition('libfive.h', 'Libraries', 'libfive_win.so')
Using MinGW64 Compiler (C++) compiler.
Generated definition file definelibfive.mlx and data file 'libfiveData.xml' contain definitions for 1 constructs supported by MATLAB.
Build using build(definelibfive).
The inclusion of the _win suffix is to distinguish that the file is a windows shared library because I did the same test for the Linux case. When I try to do a build, though, I get the following error:
>> build(definelibfive)
Building interface file 'libfiveInterface.dll'.
Error using clibgen.internal.buildHelper (line 62)
Build failed with error:
'C:/ProgramData/MATLAB/SupportPackages/R2021a_1/3P.instrset/mingw_w64.instrset/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -l-LC:\MATLAB\R2021a\extern\lib\win64\mingw64
C:/ProgramData/MATLAB/SupportPackages/R2021a_1/3P.instrset/mingw_w64.instrset/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -llibMatlabDataArray
collect2.exe: error: ld returned 1 exit status
'.
Error in clibgen.LibraryDefinition/build (line 1297)
clibgen.internal.buildHelper(obj, obj.LibraryInterface, '', directBuild);
The error is the same for both this simple example case and the more complex case. In C:\MATLAB\R2021a\extern\lib\win64\mingw64, the libMatlabDataArray.lib is present.
Accepted Answer
More Answers (0)
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!