I start with the interface between C ++ and Lisp with SWIG. I am following the SWIG documentation, but I am having a problem. Here is a simple program I want to interact with (it can be easily done in Lisp, but it must understand how to import C ++ code into Lisp):
test.cpp:
#include "test.hpp"
int test(int x, int y) {
std::cout << x+y;
return 0;
}
test.hpp:
#include <iostream>
int test(int x, int y);
To use SWIG, I create an interface file:
test.i:
%module test
%include <test.hpp>
And I ran the following command line:
$ swig -c++ -cffi test.i
$ c++ -c test_wrap.cxx
But when compiling test_wrap.cxx, the terminal says:
test_wrap.cxx:193:19: error: use of undeclared identifier 'test'
result = (int)test(arg1,arg2);
^
1 error generated.
Can anybody help me?
source
share