首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法找到表示需要链接的库的文件。

无法找到表示需要链接的库的文件。
EN

Stack Overflow用户
提问于 2020-04-10 01:23:33
回答 2查看 186关注 0票数 0

我已经构建并安装了我的目录/usr/local/lib的代码:

ls /usr/local/lib:

代码语言:javascript
复制
drwxr-xr-x 2 root root      4096 Apr  9 13:04 LibreSSL
drwxr-xr-x 3 root root      4096 Mar 20 09:54 netscape
drwxr-xr-x 2 root root      4096 Apr  9 20:06 pkgconfig
drwxrwsr-x 4 root staff     4096 Dec 28 21:56 python2.7
drwxrwsr-x 3 root staff     4096 Oct 17 09:24 python3.7
-rw-r--r-- 1 root root  21403926 Apr  8 18:05 libcrypto.a
-rwxr-xr-x 1 root root       969 Apr  8 18:05 libcrypto.la
lrwxrwxrwx 1 root root        19 Apr  8 18:05 libcrypto.so -> libcrypto.so.46.0.1
lrwxrwxrwx 1 root root        19 Apr  8 18:05 libcrypto.so.46 -> libcrypto.so.46.0.1
-rwxr-xr-x 1 root root  10741400 Apr  8 18:05 libcrypto.so.46.0.1
-rw-r--r-- 1 root root   4714494 Apr  8 18:05 libssl.a
-rwxr-xr-x 1 root root       976 Apr  8 18:05 libssl.la
lrwxrwxrwx 1 root root        16 Apr  8 18:05 libssl.so -> libssl.so.48.0.1
lrwxrwxrwx 1 root root        16 Apr  8 18:05 libssl.so.48 -> libssl.so.48.0.1
-rwxr-xr-x 1 root root   2219448 Apr  8 18:05 libssl.so.48.0.1
-rw-r--r-- 1 root root    870622 Apr  8 18:05 libtls.a
-rwxr-xr-x 1 root root      1001 Apr  8 18:05 libtls.la
lrwxrwxrwx 1 root root        16 Apr  8 18:05 libtls.so -> libtls.so.20.0.1
lrwxrwxrwx 1 root root        16 Apr  8 18:05 libtls.so.20 -> libtls.so.20.0.1
-rwxr-xr-x 1 root root    433640 Apr  8 18:05 libtls.so.20.0.1
-rwxr-xr-x 1 root root       958 Apr  9 20:06 libwolfssl.la
lrwxrwxrwx 1 root root        20 Apr  9 20:06 libwolfssl.so -> libwolfssl.so.24.0.0
lrwxrwxrwx 1 root root        20 Apr  9 20:06 libwolfssl.so.24 -> libwolfssl.so.24.0.0
-rwxr-xr-x 1 root root    473280 Apr  9 20:06 libwolfssl.so.24.0.0

我想使用来自wolfssl的hmac.h。但是,当我运行gcc -L/usr/local/lib -o my_hmac_test my_hmac_test.c -lwolfssl时,代码生成时带有一个警告,该警告稍后将寻址:

代码语言:javascript
复制
In file included from /usr/local/include/wolfssl/wolfcrypt/types.h:29,
                 from /usr/local/include/wolfssl/wolfcrypt/hash.h:29,
                 from /usr/local/include/wolfssl/wolfcrypt/hmac.h:31,
                 from my_hmac_test.c:1:
/usr/local/include/wolfssl/wolfcrypt/settings.h:2053:14: warning: #warning "For timing resistance / side-channel attack prevention consider using harden options" [-Wcpp]
 2053 |             #warning "For timing resistance / side-channel attack prevention consider using harden options"
      |              ^~~~~~~

但是,当我运行代码时。我知道这个错误:

代码语言:javascript
复制
./my_hmac_test: error while loading shared libraries: libwolfssl.so.24: cannot open shared object file: No such file or directory

我怎么才能解决这个问题?

-f -e打开gcc -L/usr/local/lib -o my_hmac_test my_hmac_test.c -lwolfssl:

代码语言:javascript
复制
strace: Process 32629 attached
In file included from /usr/local/include/wolfssl/wolfcrypt/types.h:29,
                 from /usr/local/include/wolfssl/wolfcrypt/hash.h:29,
                 from /usr/local/include/wolfssl/wolfcrypt/hmac.h:31,
                 from my_hmac_test.c:1:
/usr/local/include/wolfssl/wolfcrypt/settings.h:2053:14: warning: #warning "For timing resistance / side-channel attack prevention consider using harden options" [-Wcpp]
 2053 |             #warning "For timing resistance / side-channel attack prevention consider using harden options"
      |              ^~~~~~~
[pid 32629] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=32629, si_uid=1000, si_status=0, si_utime=2, si_stime=1} ---
strace: Process 32630 attached
[pid 32630] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=32630, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
strace: Process 32631 attached
strace: Process 32632 attached
[pid 32632] +++ exited with 0 +++
[pid 32631] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=32632, si_uid=1000, si_status=0, si_utime=1, si_stime=1} ---
[pid 32631] +++ exited with 0 +++
--- SIGCHLD {si_signo=SI
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-04-10 10:51:42

您观察到的编译器警告与运行时加载程序失败无关。

我已经构建并安装了代码到我的目录/usr/local/lib

在将任何新的共享库放置在链接器的默认搜索目录中之后,必须运行:

代码语言:javascript
复制
ldconfig

作为root,更新OS加载程序的系统库数据库。否则,在运行时,加载程序将仍然不知道新的库。在完成此操作之前,您实际上还没有完成新库的安装。如果您不这样做,那么您将不得不使用您发现的LD_LIBRARY_PATH黑客。

请参阅man ldconfig

票数 1
EN

Stack Overflow用户

发布于 2020-04-10 01:39:40

进入我的终端export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib并从同一个终端运行gcc -L/usr/local/lib -o my_hmac_test my_hmac_test.c -lwolfssl。我现在应该将导出行添加到我的.bashrc中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61132700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档