编译包装器时出现SWIG [C++ to Lisp(CFFI)]错误
SWIG [C++ to Lisp(CFFI)] error when compiling wrapper
我是一个初学者,使用SWIG在C++和Lisp之间有接口。我已经遵循了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.
有人可以帮助我吗?
这是一个修改后的test.i
,它使其余部分编译:
%module test
%{
#include "test.hpp"
%}
%include <test.hpp>
我遵循了这个演示文稿(第 24 页(,显然您需要在生成的包装器中插入 include
指令。
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- C++ Singleton - Prevent ::instance() to variable
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 如何解决"invalid conversion from 'char' to 'const char*'"
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- Python str to C++ to Python str
- 为什么创建友元类的实例会导致"undefined reference to"错误?
- System.InvalidCastException - SQL to C++ - safe_cast<float>
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- "no matching function for call to 'Vector::Vector'"错误
- vector<vector<double>> to mxArray using memcpy
- Tensorflow c++ api undefined reference to 'tflite::D efaultErrorReporter()'
- 当覆盖存在时调用基本虚拟"binded to object"函数
- OpenGL VBO Indexing ( How to compute Index Array)
- 为什么我会" void value not ignored as it ought to be"?
- 编译包装器时出现SWIG [C++ to Lisp(CFFI)]错误