I'm having trouble to use swig to wrap a c++ library for golang. Here is my c++ header file.
class Builder {
public:
explicit Builder(int i):counters(i){}
void Init();
void CreateCounters(vector<std::unique_ptr<int>>* s);
bool CreateEntry(string* primary_key);
private:
std::shared_ptr<hash_set<string>> ids;
int counters;
};
I just want to wrap Builder class and its constructor, Init() and CreateEntry function. Here is my swig API
%{
#include "builder.h"
%}
%ignoreall
%unignore Builder;
%unignore Builder::Init();
%unignore CreateEntry(string* primary_key);
%include "builder.h"
%unignoreall
But when I compile I get error pointing to the CreateCounters function which has a argument of unique_ptr vector. Can anyone tell me whats wrong in here?
Thanks in advance :)
Your swig file doesn't have a module name. Try this...
%module builder
%{
#include "builder.h"
%}
%ignoreall
%unignore Builder;
%unignore Builder::Init();
%unignore CreateEntry(string* primary_key);
%include "builder.h"
%unignoreall
The module name translates to the name of the package your wrapped code resides in.
Also for c++ code, ensure your swig file is named something like 'builder.swigcxx' the extension is important as otherwise it'll assume you're wrapping pure C.