Reputation: 2155
I have a frustrating problem which got me spend a lot of time dealing with it but I did not find any solution.
I want to use C++ class in PHP with SWIG. I generated my shared object and it works fine for some methods but I've got this error whenever I call the methods with string arguments as their input:
Fatal error: Type error in argument 2 of
PKI_Buf_initHex
. ExpectedSWIGTYPE_p_std__string
PKI_Buf_initHex
is the name of the wrapper class which SWIG made automatically. In my C++ code I declare initHex
method as:
int initHex(const string x)
{..}
I included typemaps.i
and std_string.i
in my interface file but I got the same error message.
I truly would appreciate if anyone can help me with this issue.
Upvotes: 4
Views: 9192
Reputation: 88801
You need to have:
%include <std_string.i>
Early enough in the SWIG interface (i.e. before std::string
is first seen).
Upvotes: 18