c++ - 错误的文件描述符 boost dll
问题描述
主文件
#include <boost/dll.hpp>
#include <iostream>
# include "abstract.h"
using namespace boost::dll;
int main(int argc, char* argv[]) {
boost::filesystem::path lib_path("/home/deven/Music/dllimport");
boost::shared_ptr<my_api_interface> plugin;
std::cout << "Loading the plugin" << std::endl;
plugin = import<my_api_interface>(
lib_path / "libctest.so.1.0",
"plugin",
load_mode::append_decorations
);
plugin->cal(10,20);
}
摘要.h
# ifndef ABSTRACT_H
# define ABSTRACT_H
class my_api_interface
{
public:
my_api_interface();
virtual void cal(int a ,int b) = 0;
~my_api_interface();
};
# endif
库文件
# include "abstract.h"
# include <boost/dll.hpp>
# ifndef LIB_H
# define LIB_H
namespace my_name
{
class actual_api : public my_api_interface
{
public:
actual_api();
void cal(int ,int ) ;
~actual_api();
};
extern "C" BOOST_SYMBOL_EXPORT actual_api plugin;
actual_api plugin;
}
# endif
库文件
# include "lib.h"
# include <iostream>
using std::endl;
using std::cout;
void my_name::actual_api:: cal(int a,int b)
{
cout << a+ b << endl;
}
抛出未定义符号的实例后调用错误终止:_ZN7my_name10actual_apiD1Ev):错误的文件描述符已中止(核心转储)我在linux中使用-fpic创建.so,然后使用boost.dll加载.so。我收到了这个糟糕的 fd 错误
解决方案
推荐阅读
- ios - 在单个 CAShapeLayer 中为多个 UIBezier 路径设置动画
- swift - Swift - 使用 Eureka 获取 textField 表单的值
- python - Python:为什么一个生成器比其他带有“yield”的生成器快?
- gensim - Gensim Word2Vec Model trained but not saved
- swift -
- r - r2pmml Error in .convert(tempfile, file, converter, converter_classpath, verbose) : 1
- spring-boot - Spring Boot Rest Controller API 不返回 json
- pandas - pd.describe 返回非零均值?
- php - my wamp 3.0.6 is not starting giving apache error.Can someone pleaserecommend?
- android - 需要通过登录从服务器上的自定义 API 获取令牌