编译包装器时SWIG[C+;+;to Lisp(CFFI)]错误 我是初学者,在C++和Lisp之间使用SWIG接口。我遵循了SWIG的文档,但我面临一个问题。 这里是我想连接的简单程序(它可以很容易地在LISP中完成,但它是理解如何将C++代码导入到LISP):
test.cpp:编译包装器时SWIG[C+;+;to Lisp(CFFI)]错误 我是初学者,在C++和Lisp之间使用SWIG接口。我遵循了SWIG的文档,但我面临一个问题。 这里是我想连接的简单程序(它可以很容易地在LISP中完成,但它是理解如何将C++代码导入到LISP):,c++,common-lisp,wrapper,swig,cffi,C++,Common Lisp,Wrapper,Swig,Cffi,test.cpp: #include "test.hpp" int test(int x, int y) { std::cout << x+y; return 0; } 但在编译test_wrap.cxx时,终端会显示: test_wrap.cxx:193:19: error: use of undeclared identifier 'test' result = (int)test(arg1,arg2); ^ 1 error genera
#include "test.hpp"
int test(int x, int y) {
std::cout << x+y;
return 0;
}
但在编译test_wrap.cxx时,终端会显示:
test_wrap.cxx:193:19: error: use of undeclared identifier 'test'
result = (int)test(arg1,arg2);
^
1 error generated.
任何人都可以帮我吗?这里有一个修改过的
测试。i
可以让其余部分编译:
%module test
%{
#include "test.hpp"
%}
%include <test.hpp>
%模块测试
%{
#包括“test.hpp”
%}
%包括
我遵循了(第24页),显然您需要在生成的包装中插入
include
指令。谢谢,这正是我所需要的;)
$ swig -c++ -cffi test.i
$ c++ -c test_wrap.cxx
test_wrap.cxx:193:19: error: use of undeclared identifier 'test'
result = (int)test(arg1,arg2);
^
1 error generated.
%module test
%{
#include "test.hpp"
%}
%include <test.hpp>