Error while building a c++ library interface

19 次查看(过去 30 天)
I am trying to build an interface to a C++ library I wrote following the procedure described here.
I define the missing constrcut and I receive no error whatsoever. However, when giving the command
build(definemylib)
I receive the following error
Error using clibgen.internal.buildHelper (line 75)
Build failed with error:
'C:/ProgramData/MATLAB/SupportPackages/R2021b/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:\Program Files\MATLAB\R2021b\extern\lib\win64\mingw64
C:/ProgramData/MATLAB/SupportPackages/R2021b/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 1406)
clibgen.internal.buildHelper(obj, obj.LibraryInterface, '', directBuild);
I actually do not undestand the error, since the files that cannot be found are there in the indicated folders. What am I doing wrong?

回答(1 个)

Walter Roberson
Walter Roberson 2021-11-26
-l-LC:\Program Files\MATLAB\R2021b\extern\lib\win64\mingw64
That is missing a space and also some other information.
There are two different options.
The -l (lower-case L) option needs to be followed by the name of a library to link into the object. An example of that is -llibMatlabDataArray which is saying that the libMatlabDataArray library needs to be located and linked into the object.
The -L (upper-case L) option needs to be followed by a directory name. The option indicates that the linker should add the given directory to the list of directories to search for libraries whose name have been given by -l (lower-case L) options.
Note that it is recommended that directory names with spaces in them be enclosed in double-quotes,
-L"C:\Program Files\MATLAB\R2021b\extern\lib\win64\mingw64"
  2 个评论
CaG
CaG 2021-11-27
Thank you for the answer. I know this. However, I did not write this line of code. I do not add that library folder manually. It is something created automatically inside the clibgen.internal.build command on which I have not control. I'm starting to think that maybe I am not giving all the inputs or there is something wrong with mingw64.
Walter Roberson
Walter Roberson 2021-11-27
Something is misconfigured in definemylib . The library configuration section has a typing mistake, or something like that.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by