IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> HElib搭建问题 -> 正文阅读

[C++知识库]HElib搭建问题

HElib搭建问题

一、搭建

在虚拟器中搭建HElib我就不赘述了,可以依照官网教程和博客搭建。

二、问题

前面环境都搭建好了,接下来运行样例程序的时候遇到的问题。

运行的BGV_packed_arithmetic样例程序时候,遇到如下问题:

wbw@wbw-virtual-machine:~/Desktop/HElib-master/examples/BGV_packed_arithmetic$ make
[ 50%] Building CXX object CMakeFiles/BGV_packed_arithmetic.dir/BGV_packed_arithmetic.cpp.o
In file included from /usr/local/include/helib/IndexSet.h:21:0,
                 from /usr/local/include/helib/IndexMap.h:20,
                 from /usr/local/include/helib/DoubleCRT.h:34,
                 from /usr/local/include/helib/helib.h:22,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/JsonWrapper.h:11:35: error: ‘any’ in namespace ‘std’ does not name a type
   explicit JsonWrapper(const std::any& json_repr) : json_obj(json_repr) {}
                                   ^~~
/usr/local/include/helib/JsonWrapper.h:13:14: error: ‘any’ in namespace ‘std’ does not name a type
   const std::any& getJSONobj() const { return json_obj; }
              ^~~
/usr/local/include/helib/JsonWrapper.h:23:8: error: ‘any’ in namespace ‘std’ does not name a type
   std::any json_obj;
        ^~~
/usr/local/include/helib/JsonWrapper.h: In constructor ‘helib::JsonWrapper::JsonWrapper(const int&)’:
/usr/local/include/helib/JsonWrapper.h:11:53: error: class ‘helib::JsonWrapper’ does not have any field named ‘json_obj’
   explicit JsonWrapper(const std::any& json_repr) : json_obj(json_repr) {}
                                                     ^~~~~~~~
/usr/local/include/helib/JsonWrapper.h: In member function ‘helib::JsonWrapper::operator bool() const’:
/usr/local/include/helib/JsonWrapper.h:12:43: error: ‘json_obj’ was not declared in this scope
   explicit operator bool() const { return json_obj.has_value(); }
                                           ^~~~~~~~
In file included from /usr/local/include/helib/Context.h:27:0,
                 from /usr/local/include/helib/helib.h:23,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/scheme.h: At global scope:
/usr/local/include/helib/scheme.h:39:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view schemeName = "CKKS";
                         ^~~~~~~~~~~
/usr/local/include/helib/scheme.h:56:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view schemeName = "BGV";
                         ^~~~~~~~~~~
In file included from /usr/local/include/helib/helib.h:23:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/Context.h:212:22: error: ‘optional’ in namespace ‘std’ does not name a template type
           const std::optional<ModChainParams>& mparams,
                      ^~~~~~~~
/usr/local/include/helib/Context.h:212:30: error: expected ‘,’ or ‘...’ before ‘<’ token
           const std::optional<ModChainParams>& mparams,
                              ^
/usr/local/include/helib/Context.h:244:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "Context";
                         ^~~~~~~~~~~
/usr/local/include/helib/Context.h:1057:24: error: ‘optional’ is not a member of ‘std’
   const std::pair<std::optional<Context::ModChainParams>,
                        ^~~~~~~~
/usr/local/include/helib/Context.h:1057:24: note: suggested alternative: ‘internal’
   const std::pair<std::optional<Context::ModChainParams>,
                        ^~~~~~~~
                        internal
/usr/local/include/helib/Context.h:1057:24: error: ‘optional’ is not a member of ‘std’
/usr/local/include/helib/Context.h:1057:24: note: suggested alternative: ‘internal’
   const std::pair<std::optional<Context::ModChainParams>,
                        ^~~~~~~~
                        internal
/usr/local/include/helib/Context.h:1057:56: error: wrong number of template arguments (1, should be 2)
   const std::pair<std::optional<Context::ModChainParams>,
                                                        ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:18:
/usr/include/c++/7/bits/stl_pair.h:208:12: note: provided for ‘template<class _T1, class _T2> struct std::pair’
     struct pair
            ^~~~
In file included from /usr/local/include/helib/helib.h:23:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/Context.h:1057:57: error: expected unqualified-id before ‘,’ token
   const std::pair<std::optional<Context::ModChainParams>,
                                                         ^
/usr/local/include/helib/Context.h:1094:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "ContextBuilder";
                         ^~~~~~~~~~~
In file included from /usr/local/include/helib/helib.h:24:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/Ctxt.h:510:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "Ctxt";
                         ^~~~~~~~~~~
In file included from /usr/local/include/helib/helib.h:25:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/keySwitching.h:93:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "KeySwitch";
                         ^~~~~~~~~~~
In file included from /usr/local/include/helib/helib.h:26:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/keys.h:77:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "PubKey";
                         ^~~~~~~~~~~
/usr/local/include/helib/keys.h:322:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "SecKey";
                         ^~~~~~~~~~~
In file included from /usr/local/include/helib/helib.h:27:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/EncryptedArray.h:2173:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "PtxtArray";
                         ^~~~~~~~~~~
In file included from /usr/local/include/helib/helib.h:28:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/Ptxt.h:199:25: error: ‘string_view’ in namespace ‘std’ does not name a type
   static constexpr std::string_view typeName = "Ptxt";
                         ^~~~~~~~~~~
/home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp: In function ‘int main(int, char**)’:
/home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:59:39: error: use of deleted function ‘helib::Context::Context(helib::Context&&)’
                                .build();
                                       ^
In file included from /usr/local/include/helib/helib.h:23:0,
                 from /home/wbw/Desktop/HElib-master/examples/BGV_packed_arithmetic/BGV_packed_arithmetic.cpp:20:
/usr/local/include/helib/Context.h:671:3: note: declared here
   Context(Context&& other) = delete;
   ^~~~~~~
CMakeFiles/BGV_packed_arithmetic.dir/build.make:62: recipe for target 'CMakeFiles/BGV_packed_arithmetic.dir/BGV_packed_arithmetic.cpp.o' failed
make[2]: *** [CMakeFiles/BGV_packed_arithmetic.dir/BGV_packed_arithmetic.cpp.o] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/BGV_packed_arithmetic.dir/all' failed
make[1]: *** [CMakeFiles/BGV_packed_arithmetic.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

三、解决

经大神帮助,发现是由于样例程序是使用C++17新特性带来的问题,因此需要在你的运行 CMakeLists.txt添加下列语句

wbw@wbw-virtual-machine:~/Desktop/HElib-master/examples/BGV_packed_arithmetic$ ls
BGV_packed_arithmetic      CMakeCache.txt  cmake_install.cmake  helib.log
BGV_packed_arithmetic.cpp  CMakeFiles      CMakeLists.txt       Makefile
wbw@wbw-virtual-machine:~/Desktop/HElib-master/examples/BGV_packed_arithmetic$ vim CMakeCache.txt

添加内容

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(helib)

add_executable(BGV_packed_arithmetic BGV_packed_arithmetic.cpp)

target_link_libraries(BGV_packed_arithmetic helib)

运行成功截图
在这里插入图片描述

  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章      下一篇文章      查看所有文章
加:2022-03-30 18:05:26  更:2022-03-30 18:07:47 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 3:09:45-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码