gpt4 book ai didi

c - 为什么 libonion 的 websockets.c 示例给出错误 "Cant calculate SHA1 if gnutls is not compiled in!"

转载 作者:太空宇宙 更新时间:2023-11-03 23:19:15 25 4
gpt4 key购买 nike

我正在尝试运行 libonion ( https://github.com/davidmoreno/onion/tree/master/examples/websockets ) 的 websockets.c 示例。但是,当我运行它时,它给出了这个错误。

“[ERROR codecs.c:389] 如果没有编译 gnutls,则无法计算 SHA1!现在中止”

其他示例运行良好。

我正在编译:

$ gcc -o muz websockets.c -I$ONION_DIR/src/-L$ONION_DIR/src/onion/-lonion_static -Lpam -Lgnutls -Lgcrypt -lpthread

终端输出如下。

[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:216] Ignoring SIGPIPE
[49CDC700] [2017-08-21 11:26:12] [DEBUG poller.c:328] Init thread stuff for poll. Eventfd at 4
[49CDC700] [2017-08-21 11:26:12] [DEBUG poller.c:328] Init thread stuff for poll. Eventfd at 4
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:649] add 0x136a400 listen_point (0x136a470, 0x136a400, (nil))
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:461] Created default HTTP listen port
[49CDC700] [2017-08-21 11:26:12] [DEBUG listen_point.c:192] Trying to listen at (null):8080
[49CDC700] [2017-08-21 11:26:12] [DEBUG listen_point.c:233] Listening to 0.0.0.0:8080, fd 6
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:507] Adding listen point fd 6 to poller
[49CDC700] [2017-08-21 11:26:12] [DEBUG onion.c:515] Start polling / listening 0x136a470, 0x136a400, (nil)
[494F1700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[48CF0700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[474ED700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[47CEE700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[484EF700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[46CEC700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[49CDC700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[464EB700] [2017-08-21 11:26:12] [DEBUG poller.c:497] Start polling
[464EB700] [2017-08-21 11:26:26] [DEBUG response.c:104] Recalculating date header
[464EB700] [2017-08-21 11:26:26] [INFO response.c:189] [127.0.0.1] "GET /" 200 501 (Keep-Alive)
[464EB700] [2017-08-21 11:26:26] [DEBUG websocket.c:88] Websockets!
[464EB700] [2017-08-21 11:26:26] [ERROR codecs.c:389] Cant calculate SHA1 if gnutls is not compiled in! Aborting now

最佳答案

应该不需要单独编译示例,它应该会随着整个项目自动编译。例如,如果您在主包目录中,请创建一个干净的目录并从中运行 cmake:

mkdir build && cd build
cmake ..

然后查看 cmake 的输出并确保找到所有第 3 方库和其他依赖项。对于 gnutls,它应该如下所示:

-- Found GnuTLS: /usr/lib/libgnutls.so (found version "3.5.13")
-- Found GCrypt: /usr/include (found version "1.7.7")
-- SSL support is compiled in.

如果您收到如下错误消息:

Gnutls or gcrypt not found. SSL support is not compiled in.

,您必须确保 libgnutls.so 已安装并且可以在默认搜索路径中找到(例如 /usr/lib/)。

修复 cmake 错误并运行 make 后,您应该可以在 examples/websockets/websockets 中找到示例。

关于c - 为什么 libonion 的 websockets.c 示例给出错误 "Cant calculate SHA1 if gnutls is not compiled in!",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45792792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com