【发布时间】:2017-02-14 23:46:09
【问题描述】:
我正在尝试使用 libsodium 制作一个测试应用程序,但是我收到了错误:
main.cpp:6: undefined reference to `sodium_init'
我以 root 用户身份运行以下命令进行安装。
$ ./configure
$ make && make check
$ make install
这是有问题的代码。
#include <stdio.h>
#include <sodium.h>
int main(int argc, char **argv)
{
if (sodium_init() == -1)
{
return 1;
}
printf("libsodium had no issues!\n");
return 0;
}
我使用 CodeLite 作为我的 IDE,我的 C++ 编译器选项如下:
-g;-O0;-Wall;-lsodium
这些选项是默认的,我将-lsodium 添加到列表中。
尝试使用以下命令 g++ -lsodium main.cpp 直接从终端编译 main.cpp 会引发相同的错误。
有人可以帮我解决我的问题吗?
【问题讨论】:
标签: c++ cryptography codelite libsodium nacl-cryptography