error when building interface file for clib package

7 visualizzazioni (ultimi 30 giorni)
JoRo
JoRo il 7 Mar 2023
Modificato: Kartik il 16 Mag 2023
Hi,
I am working on matlab 2022a and I am trying to build an interface file for a clib package.
  • Therefore I installed the MinGW g++ compiler (Rev 10, Built by MSYS2 project) 12.2.0.
  • I also installed the matlab add-on Matlab Support for MinGW-w64 C/C++ Compiler.
  • Furthermore, I added the userspecific environment variable "MW_MINGW64_LOC" with the path "C:\msys64\mingw64" and I added the path to the "Path"-variable
When running:
>> mex -setup cpp
MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation.
so it seems to work.
But when running build() it get the following error:
>> build(defineTestlib)
Building interface file 'TestlibInterface.dll' for clib package 'Testlib'.
Error using clibgen.internal.buildHelper (line 75)
Build failed with error:
'C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -l-LC:\Program
Files\MATLAB\R2021b\extern\lib\win64\mingw64: Invalid argument
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llibMatlabDataArray: No such file
or directory
collect2.exe: error: ld returned 1 exit status
'.
Error in clibgen.LibraryDefinition/build (line 1406)
clibgen.internal.buildHelper(obj, obj.LibraryInterface, '', directBuild);
Can anyone help me that it works?
Best regards

Risposte (1)

Kartik
Kartik il 16 Mag 2023
Modificato: Kartik il 16 Mag 2023
Hi,
The error message suggests that the linker is unable to find two required libraries: libMatlabDataArray and lib-LC:\Program Files\MATLAB\R2021b\extern\lib\win64\mingw64. The first library is a precompiled MATLAB library that is required for generating the interface file, while the second library is likely a misconfigured library path.
Here are a few potential solutions to try:
  1. Confirm that the MW_MINGW64_LOC environment variable points to the correct folder containing the MinGW g++ compiler. It should point to the root directory containing bin, include, lib subdirectories.
  2. Edit the libPaths parameter in your LibraryDefinition object to include the path to the MATLAB libraries that the linker is looking for. You can add or modify paths using the libPaths parameter, e.g.:
options.libPaths = {'C:\Program Files\MATLAB\R2021b\extern\lib\win64\mingw64'};
Make sure that the path specified in libPaths exists on your system and is correct.
3. Check if you have the required version of the MinGW-w64 compiler. The Matlab Support for MinGW-w64 C/C++. Compiler add-on that you installed is compatible with version 8.2.0 of the MinGW-w64 compiler. If your version is not compatible, you may need to switch to a compatible version.
4. Try using a different compiler and see if that solves the issue. You can use Microsoft Visual Studio as an alternative C++ compiler.
5. Check that you have the required libraries installed for the version of MATLAB you are using. The libraries can be found in the MATLAB extern/lib/win64/mingw64 directory, and should include files like libMatlabDataArray.lib.
Hopefully one of these solutions can help resolve the issue.

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by