On Wed, Sep 16, 2015 at 6:13 PM, Ronoaldo Pereira <
rono...@gmail.com> wrote:
>
> Constants / Enums: OpenCV defines a set of enums with integer constants. I
> was unable to make SWIG see them. I have attempted using %include
> <opencv2/core/core.cpp> for instance, but that failed an "unable to find
> file" error message. I had to redefine the constants in my .i file with
> #define. Is that the right approach in these cases?
I see from the gist that you seem to really be using a .i file. But
below you discuss a .swig file. Which approach are you using?
Doing a %include of a .cpp file doesn't make much sense. Are the enum
values define in a .h file that you could %include?
Redefining the constants yourself seems like a last resort.
> While building the .i file for swig, there was no easy way to "see" the
> generated Go API. For instance, I forgot to add the public keyword to the
> class methods in the .i file, and Swig was not generating them. However,
> doing a go test -v the output was just "undefined method NewSize2i". I
> discovered inspecting the build flags that with -work flag, I could see the
> generated output by swig and check the generated methods in Go. Is there an
> easier way to inspect the swig generated go API? I.e., is there a way to see
> the godoc output of what swig generates?
There is no good way to inspect the SWIG generated Go API. Using
-work as you did is the best approach.
> I am willing to write some tools to parse the Open CV API from the website
> and generate .i files for each module automatically, but I don't know if
> this even make sense. Does anyone have done this for other libraries with
> SWIG and Go? Does it worth the hassle? I see that the Open GL Bindings are
> generated automatically with tooling, and I liked the approach, but was
> unable to understand where to begin doing something similar to OpenCV.
SWIG can in effect auto-generate the .swig file for you, in the sense
that SWIG can produce definitions for every function declared in the
.h files that it includes. Just %include the file outside of %{ %}.
> I would like to use the resulting package in other projects. When using
> swig, should I first generate the Go bindings manually (swig -go ...), so it
> is go gettable, or it is enough to have the .swigcxx file to `go get` the
> package.
I think that having the .swigcxx file is sufficient.
Ian