如何正确链接libssh?

编程入门 行业动态 更新时间:2024-10-19 19:47:19
本文介绍了如何正确链接libssh?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正尝试在我的代码(libssh)中包含一个lib,但没有任何效果... 此时我不确定该怎么办,因为搜索结果中没有错误提示我我正在接收。

I'm trying to include a lib into my code (libssh) but nothing works... At this point I'm unsure what to do as no results are popping up in search engines for the errors i'm recieving.

我在这里下载了libssh: github/substack/libssh

I downloaded libssh here: github/substack/libssh

我安装了这些文件:

yum install cmake zlib-devel libpng-devel openssl-devel -y;

作为libssh的父目录创建一个 build目录,移至该目录,键入:

Created a "build" directory as parent of libssh, moved there, typed this:

cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug .. make [root@ build]# cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug LD_DEBUG=all .. -- Could NOT find NaCl (missing: NACL_LIBRARIES NACL_INCLUDE_DIRS) -- ******************************************** -- ********** libssh build options : ********** -- zlib support: ON -- libgcrypt support: OFF -- libnacl support: OFF -- SSH-1 support: OFF -- SFTP support: ON -- Server support : ON -- GSSAPI support : ON -- Pcap debugging support : ON -- With static library: OFF -- Unit testing: OFF -- Client code Unit testing: OFF -- Public API documentation generation -- Benchmarks: OFF -- ******************************************** -- Configuring done -- Generating done -- Build files have been written to: /root/libssh/build

然后失败...

Scanning dependencies of target exec [ 2%] Building C object examples/CMakeFiles/exec.dir/exec.c.o [ 5%] Building C object examples/CMakeFiles/exec.dir/authentication.c.o [ 8%] Building C object examples/CMakeFiles/exec.dir/knownhosts.c.o [ 11%] Building C object examples/CMakeFiles/exec.dir/connect_ssh.c.o Linking C executable exec /usr/bin/ld: cannot find -lssh_shared collect2: ld a retourné 1 code d'état d'exécution make[2]: *** [examples/exec] Erreur 1 make[1]: *** [examples/CMakeFiles/exec.dir/all] Erreur 2 make: *** [all] Erreur 2

有人知道是什么问题吗? 找不到-lssh_shared显示与Google无关。

Anyone know what the problem is? "cannot find -lssh_shared" showed me nothing related on google.

推荐答案

错误消息是由链接器 / usr / bin / ld 在编译时无法链接到库 ssh_shared.so 。

The error message is resulted from the linker /usr/bin/ld is failed to link to the library ssh_shared.so while compiling.

我检查了文件 libssh / build / src / CMakeFiles / ssh_shared.dir / build.make ,在内部链接消息:

I checked the file libssh/build/src/CMakeFiles/ssh_shared.dir/build.make, there's some linking messages inside:

ssh_shared_EXTERNAL_OBJECTS = src/libssh.so.4.2.0: /usr/lib/x86_64-linux-gnu/libz.so src/libssh.so.4.2.0: /usr/lib/x86_64-linux-gnu/libssl.so src/libssh.so.4.2.0: /usr/lib/x86_64-linux-gnu/libcrypto.so ... (snippet here) ... src/libssh.so.4.2.0: src/CMakeFiles/ssh_shared.dir/bind.c.o src/libssh.so.4.2.0: /usr/lib/x86_64-linux-gnu/libz.so src/libssh.so.4.2.0: /usr/lib/x86_64-linux-gnu/libssl.so src/libssh.so.4.2.0: /usr/lib/x86_64-linux-gnu/libcrypto.so src/libssh.so.4.2.0: src/CMakeFiles/ssh_shared.dir/build.make src/libssh.so.4.2.0: src/CMakeFiles/ssh_shared.dir/link.txt @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking C shared library libssh.so"

您会注意到在构建过程中s, cmake 会尝试在我的系统路径 / usr / lib / x86_64-linux-gnu / 下链接某些库。然后去检查你的。

You can notice that during the build process, cmake would try to link some libraries under my system path /usr/lib/x86_64-linux-gnu/. And go to check yours.

更多推荐

如何正确链接libssh?

本文发布于:2023-10-13 10:09:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1487657.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何正确   链接   libssh

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!