Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Using the following in the SWIG interface file:
Running the following perl:%module mycpp %include "std_vector.i" namespace std { %template(IntVector) vector<int>; } extern double average(std::vector<int> v); Having the C++ file as follows: #include <vector> #include <algorithm> #include <functional> #include <numeric> double average(std::vector<int> v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); }
I got the following error message:use mycpp; ny $sv = mycpp::IntVector(); $sv->push(1); $sv->push(2); $sv->push(3); $sv->push(4); $avg = average($sv);
Could someone please tell how to rectify this error and how to call C++ vector of integer from perl.Can't locate auto/mycpp/IntVector.al in @INC (@INC contains: /usr/perl5/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/prel5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at mycpp.pl lin +e 2.
Thanx.
|
|---|