nodejs的c++插件中应有的类名
expected class name in c++ addon for nodejs
我正在为nodejs开发一个c++插件。这是一个概率滤波器。我需要做的是将现有的c++库绑定到nodejs。我遵循中的文件说明https://nodejs.org/docs/latest/api/addons.html#addons_wrapping_c_objects
我在github中有另一个例子,它向我展示了c++中的概率过滤器是如何绑定到nodejs的:https://github.com/bbondy/bloom-filter-cpp.
我尝试将自己的c++库转换为nodejs插件。我现在已经完成了编码,我试图用binding.gyp单独构建它。但总有一个错误:错误
然而,我确实在课堂上加入了SimdBlockFilter:这是simd_block_wrap.h的代码:
#ifndef simd_block_wrap_hpp
#define simd_block_wrap_hpp
#include <node.h>
#include <node_object_wrap.h>
#include "SimdBlockFilter.h"
namespace simd_block_wrap {
class simd_block_wrap : public SimdBlockFilter, public node::ObjectWrap {
public:
static void Init(v8::Local<v8::Object> exports);
simd_block_wrap(const int log_heap_space);
private:
virtual ~simd_block_wrap();
static void Add(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Find(const v8::FunctionCallbackInfo<v8::Value>& args);
static v8::Persistent<v8::Function> constructor;
};
}
#endif /* simd_block_wrap_hpp */
这是绑定的代码。gyp:
{
"targets": [{
"target_name": "addon",
"sources": [
"addon.cpp",
"SimdBlockFilter.h",
"simd_block_wrap.cpp",
"simd_block_wrap.h",
"hashutil.cc",
"hashutil.h",
],
"xcode_settings": {
"OTHER_CFLAGS": [ "-ObjC" ],
"OTHER_CPLUSPLUSFLAGS" : ["-std=c++11","-stdlib=libc++", "-v"],
"MACOSX_DEPLOYMENT_TARGET": "10.9",
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
},
}]
}
以及c++库 SimdBlockFilter.h的代码
#pragma once
#include <cstdint>
#include <cstdlib>
#include <algorithm>
#include <new>
#include <immintrin.h>
#include "hashutil.h"
using uint32_t = ::std::uint32_t;
using uint64_t = ::std::uint64_t;
template<typename HashFamily =
::cuckoofilter::TwoIndependentMultiplyShift>
class SimdBlockFilter {
private:
// The filter is divided up into Buckets:
using Bucket = uint32_t[8];
// log2(number of bytes in a bucket):
static constexpr int LOG_BUCKET_BYTE_SIZE = 5;
static_assert(
(1 << LOG_BUCKET_BYTE_SIZE) == sizeof(Bucket) && sizeof(Bucket) == sizeof(__m256i),
"Bucket sizing has gone awry.");
// log_num_buckets_ is the log (base 2) of the number of buckets in the directory:
const int log_num_buckets_;
// directory_mask_ is (1 << log_num_buckets_) - 1. It is precomputed in the contructor
// for efficiency reasons:
const uint32_t directory_mask_;
Bucket* directory_;
HashFamily hasher_;
public:
// Consumes at most (1 << log_heap_space) bytes on the heap:
explicit SimdBlockFilter(const int log_heap_space);
SimdBlockFilter(SimdBlockFilter&& that)
: log_num_buckets_(that.log_num_buckets_),
directory_mask_(that.directory_mask_),
directory_(that.directory_),
hasher_(that.hasher_) {}
~SimdBlockFilter() noexcept;
void Add(const uint64_t key) noexcept;
bool Find(const uint64_t key) const noexcept;
uint64_t SizeInBytes() const { return sizeof(Bucket) * (1ull << log_num_buckets_); }
private:
// A helper function for Insert()/Find(). Turns a 32-bit hash into a 256-bit Bucket
// with 1 single 1-bit set in each 32-bit lane.
static __m256i MakeMask(const uint32_t hash) noexcept;
SimdBlockFilter(const SimdBlockFilter&) = delete;
void operator=(const SimdBlockFilter&) = delete;
};
提前谢谢。
这可能意味着您的包含路径设置不正确。尝试将'include_dirs': ["include/path/for/SimdBlockFilter"]
添加到binding.gyp.
您的源文件中也应该有#include "v8.h"
。
相关文章:
- 从C++本机插件更新Vector3数组
- 使用CMake创建QML插件
- 停止cmake target_link_libraries将插件中静态库的两个对象文件链接到静态库本身
- 如何创建从Maya(或类似程序)到虚幻引擎的自定义数据导出插件
- clang 插件:在编译过程中修改 AST
- 实现动态插件管理器
- 我想通过带有C++和Python的插件创建一个可扩展的应用程序
- Agora.io 虚幻引擎插件构建错误
- 使用带有C++对象和标准库容器的插件系统
- 运行命令 "rosbag play example.bag" 时出错。找不到与插件 rosbag/NoEncryptor 对应的库
- 编译 llvm 插件时出现问题:llvm/Config/llvm-config.h:没有这样的文件或目录
- 通过 Gazebo 世界插件将静态对象附加到机器人链接
- 如何为模块化应用程序实现C++插件系统
- 'string'文件在带有C++文件的iOS插件上找不到
- 在 Android 上安装 GStreamer 插件
- 如何使用MSVC 2019创建和使用Qt 5.14.0自定义小工具插件
- 如何在 Windows 操作系统中在 geany 中安装插件
- 节点插件 API 将数组作为函数参数传递
- OpenVINO - 推理库插件 libMKLDNNPlugin.so 无法解析依赖关系
- 通过 Flutter 从C++插件访问资产