borglab/gtsam

Error compilining a new class and GTSAM_EXPORT to Matlab

etamarlu opened this issue · 1 comments

I am using this example to expose some of functionalities to Matlab, got it to work with functions, but now when I try to create a class compilation fails.

Description

Steps to reproduce

I simplified the code as much as I could, to reproduce the error:

  1. in PrintExamples.h, under "namespace example" :
class GTSAM_EXPORT IsamBatch {	
  public:
    IsamBatch(ISAM2Params& parameters, double smootherLag );
    
    ~IsamBatch() {
    }
    
    void print(const std::string& s) const;
};
  1. in the cpp file under the "namespace example":
IsamBatch::IsamBatch(ISAM2Params& parameters , double smootherLag = 0.0 ) {};
  1. In example.i under namespace example add:
virtual class IsamBatch{	
    IsamBatch(ISAM2Params& parameters, double smootherLag);
    ~IsamBatch() 
    void serializable() const;

}
  1. continue with the example instruction (cmake build .. , make -j8, etc..)

Expected behavior

Environment

Ubuntu 22

Additional information

The error:

[ 60%] Generating wrap/example_matlab/example_matlab_wrapper.cpp
[MatlabWrapper] Ignoring classes: []
Traceback (most recent call last):
  File "/usr/local/bin/gtwrap/matlab_wrap.py", line 66, in <module>
    cc_content = wrapper.wrap(sources, path=args.out)
  File "/usr/local/lib/gtwrap/gtwrap/matlab_wrapper/wrapper.py", line 1915, in wrap
    parsed_result = parser.Module.parseString(content)
  File "/usr/local/lib/gtwrap/gtwrap/interface_parser/module.py", line 56, in parseString
    return Module.rule.parseString(s)[0]
  File "/usr/lib/python3/dist-packages/pyparsing.py", line 1955, in parseString
    raise exc
  File "/usr/lib/python3/dist-packages/pyparsing.py", line 3814, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected stringEnd, found 'n'  (at char 987), (line:34, col:1)
make[2]: *** [CMakeFiles/example_matlab_matlab_wrapper.dir/build.make:74: wrap/example_matlab/example_matlab_wrapper.cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:371: CMakeFiles/example_matlab_matlab_wrapper.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

We don't support destructors in the wrapper and you're missing a semi-colon after the closing curly braces of the class. The correct wrapper definition would look like

virtual class IsamBatch{	
    IsamBatch(ISAM2Params& parameters, double smootherLag);
    void serializable() const;
};