我是 C++ 和 Lisp 与 SWIG 之间接口的初学者。我已经按照 SWIG 的文档进行操作,但我遇到了问题。这是我想要接口的简单程序(它可以在 Lisp 中轻松完成,但它是为了了解如何将 C++ 代码导入 Lisp):
测试.cpp:
#include "test.hpp"
int test(int x, int y) {
std::cout << x+y;
return 0;
}
测试.hpp:
#include <iostream>
int test(int x, int y);
为了使用 SWIG,我创建了接口文件:
测试.i:
%module test
%include <test.hpp>
而且,我执行了以下命令行:
$ swig -c++ -cffi test.i
$ c++ -c test_wrap.cxx
但是在编译 test_wrap.cxx 时,终端会说:
test_wrap.cxx:193:19: error: use of undeclared identifier 'test'
result = (int)test(arg1,arg2);
^
1 error generated.
任何人都可以帮助我吗?