Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Botan Autoseed\u RNG无法初始化,未知引用,尽管LIB链接正确_C++_Botan - Fatal编程技术网

C++ Botan Autoseed\u RNG无法初始化,未知引用,尽管LIB链接正确

C++ Botan Autoseed\u RNG无法初始化,未知引用,尽管LIB链接正确,c++,botan,C++,Botan,我只是尝试初始化Botan Autoseed\u RNG,但由于引用错误而失败。我只是想测试我是否可以初始化任何类型的植物学RNG,因为我在另一个项目中遇到了麻烦 我包含了正确的标题,并且正在链接到Botan的库,因此我不知道为什么它找不到引用 这是我的密码: 1 #include <botan/auto_rng.h> 2 #include <botan/ecdh.h> 3 #include <botan/ec_group.h> 4 #incl

我只是尝试初始化Botan Autoseed\u RNG,但由于引用错误而失败。我只是想测试我是否可以初始化任何类型的植物学RNG,因为我在另一个项目中遇到了麻烦

我包含了正确的标题,并且正在链接到Botan的库,因此我不知道为什么它找不到引用

这是我的密码:

  1 #include <botan/auto_rng.h>
  2 #include <botan/ecdh.h>
  3 #include <botan/ec_group.h>
  4 #include <botan/pubkey.h>
  5 #include <botan/hex.h>
  6 #include <iostream>
  7
  8 int main() {
  9
 10     Botan::AutoSeeded_RNG rng;
 11
 12     return 0;
 13 }
 14
我做错了什么


谢谢您的建议。

您没有链接到植物学图书馆。
-L
标志仅将目录添加到库搜索路径中,它不告诉
g++
链接任何特定库。要链接库,必须使用
-l
参数。然后链接器将在其库搜索路径中搜索此库,包括通过
-L
传递的目录

要链接到botan库,您必须找到包含botan库的目录。我知道你的情况是
/usr/local/lib/libbotan-2。然后将
-lbotan-2
参数添加到
g++
参数列表中。这将使
g++
在其库搜索路径中查找名为
libbotan-2的库。由于您使用
-L/usr/local/lib
参数将
/usr/local/lib
添加到库搜索路径中,
g++
应该能够在此文件夹中找到库

请注意,为了获得最佳体验,botan图书馆可能需要或推荐其他参数。您可以在名为
botan-2.pc
的文件中找到这些参数,该文件应包含在自定义安装中的某个位置。在我的系统上,它包含以下信息:

$ cat /usr/lib/pkgconfig/botan-2.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib
includedir=${prefix}/include/botan-2

Name: Botan
Description: Crypto and TLS for C++11
Version: 2.15.0

Libs: -L${libdir} -lbotan-2 -fstack-protector -m64 -pthread
Libs.private: -lbz2 -ldl -llzma -lrt -lz
Cflags: -I${includedir}
也可以使用
pkg config
命令直接查询此信息:

$ PKG_CONFIG_PATH=/some/path:$PKG_CONFIG_PATH pkg-config --libs --cflags botan-2
-I/usr/include/botan-2 -lbotan-2 -fstack-protector -m64 -pthread
其中
/some/path
是包含
botan-2.pc
的目录。这为我们提供了botan库推荐的编译器和链接器标志。我们可以手动将它们复制到g++参数列表中,或者使用以下命令自动传递它们:

g++ $(PKG_CONFIG_PATH=/some/path:$PKG_CONFIG_PATH pkg-config --libs --cflags botan-2) my_program.cpp

你没有链接到植物学图书馆。
-L
标志仅将目录添加到库搜索路径中,它不告诉
g++
链接任何特定库。要链接库,必须使用
-l
参数。然后链接器将在其库搜索路径中搜索此库,包括通过
-L
传递的目录

要链接到botan库,您必须找到包含botan库的目录。我知道你的情况是
/usr/local/lib/libbotan-2。然后将
-lbotan-2
参数添加到
g++
参数列表中。这将使
g++
在其库搜索路径中查找名为
libbotan-2的库。由于您使用
-L/usr/local/lib
参数将
/usr/local/lib
添加到库搜索路径中,
g++
应该能够在此文件夹中找到库

请注意,为了获得最佳体验,botan图书馆可能需要或推荐其他参数。您可以在名为
botan-2.pc
的文件中找到这些参数,该文件应包含在自定义安装中的某个位置。在我的系统上,它包含以下信息:

$ cat /usr/lib/pkgconfig/botan-2.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib
includedir=${prefix}/include/botan-2

Name: Botan
Description: Crypto and TLS for C++11
Version: 2.15.0

Libs: -L${libdir} -lbotan-2 -fstack-protector -m64 -pthread
Libs.private: -lbz2 -ldl -llzma -lrt -lz
Cflags: -I${includedir}
也可以使用
pkg config
命令直接查询此信息:

$ PKG_CONFIG_PATH=/some/path:$PKG_CONFIG_PATH pkg-config --libs --cflags botan-2
-I/usr/include/botan-2 -lbotan-2 -fstack-protector -m64 -pthread
其中
/some/path
是包含
botan-2.pc
的目录。这为我们提供了botan库推荐的编译器和链接器标志。我们可以手动将它们复制到g++参数列表中,或者使用以下命令自动传递它们:

g++ $(PKG_CONFIG_PATH=/some/path:$PKG_CONFIG_PATH pkg-config --libs --cflags botan-2) my_program.cpp