Errors Creating a C++ Library Interface

조회 수: 12(최근 30일)
Christopher Dadswell
Christopher Dadswell 2020년 10월 6일
편집: Lukás Tomek 2021년 1월 20일
Hi all,
I'm trying to create a Matlab interface to a large C++ library using the clibgen function. The library in question has been automatically generated from another software package and I've been using it develop C++ applications for the last 6 months or so, but there's now an additional requirement on the project to provide a Matlab interface. The Matlab 'Interface to C++ Library' sounds like it should do the job but all the examples and documentation are on relatively small and simple libraries. Mine has 200+ source files with headers to match, and depends on several libraries which I have in .dll & .lib form. I've tried to build the interface from both a compiled .lib of the source code, and from the source code directly in the following manner:
% Setup mex
mex -v -setup:'C:\Program Files\MATLAB\R2020b\bin\win64\mexopts\msvcpp2017.xml' C++ COMPFLAGS='$COMPFLAGS -std=C++98'
% Generate the library definition
clibgen.generateLibraryDefinition(headerFiles', ...
'SupportingSourceFiles', srcFiles', ...
'Libraries', libFiles', ...
'IncludePath', incPath, ...
'Verbose', true, ...
'ReturnCArrays', false, ...
'PackageName', myPkg)
I've omitted all the set up of the variables for brevity, but these are all just strings or string arrays defining the paths and the list of source and header files to be used. I've included the .lib files that the code base depends on in the 'libFiles' variable. Honestly this is a complete guess as to whether this is the correct usage, as the documentation only gives examples of this parameter being used to associate a single library with a single header file. The help function does say that this variable can be string array, so I by inferrence it seems I should be able to link multiple libraries in this way.
Running the code leads to Matlab spending a very long time parsing the code, then spitting out a huge list of errors that completely fills the console. 99% of them seem to be 'dynamic exception specifications are deprecated.' errors. I think that this is a problem with the C++ standard that Matlab is expecting vs. the standard the library has been generated (C++ 98). It's not really viable for me to rewrite the code to remove the deprecated code, so I've tried to account for this issue in my mex setup by setting '-std=C++98', but this doesn't seem to have had any effect. Does anyone if this is the right way to force a particular C++ standard on the compiler? The other type of error I seem to get is 'variable <insert name here> was declared but never referenced', which again I'm not really sure how to fix. These both seem like they should perhaps be warnings rather than errors. Anyone know if there's way to suppress these issues?
Thanks very much,
  댓글 수: 1
Lukás Tomek
Lukás Tomek 2021년 1월 20일
편집: Lukás Tomek 2021년 1월 20일
Hi Chris,
did you manage to solve this? Now I try to solve the same problem for some large labrary with tons of .h, .cpp, .lib files.
Thank you,

댓글을 달려면 로그인하십시오.





Community Treasure Hunt

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

Start Hunting!

Translated by