dyld:库未加载。没有这个文件

问题描述 投票:0回答:1
h@Hrvojes-MacBook-Pro problemSet2 % ./hours                      
dyld[18659]: Library not loaded: libcs50-11.0.2.dylib
  Referenced from: <099E85B4-69E7-3DB9-BBCB-261540A924DC> /Users/h/CS50 Learning/2.ARRAYS/problemSet2/hours
  Reason: tried: 'libcs50-11.0.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcs50-11.0.2.dylib' (no such file), 'libcs50-11.0.2.dylib' (no such file), '/Users/h/CS50 Learning/2.ARRAYS/problemSet2/libcs50-11.0.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/h/CS50 Learning/2.ARRAYS/problemSet2/libcs50-11.0.2.dylib' (no such file), '/Users/h/CS50 Learning/2.ARRAYS/problemSet2/libcs50-11.0.2.dylib' (no such file)
zsh: abort      ./hours

我尝试运行我编写的一个简单程序,但它无法编译。

c cs50 dyld nosuchfileexception
1个回答
0
投票

您需要安装和/或找到它正在寻找的动态库:libcs50


在 mac OS 上安装的说明是(从README.md复制):

来自源代码(Linux 和 Mac)

  1. https://github.com/cs50/libcs50/releases下载最新版本
  2. 提取
    libcs50-*.*
  3. cd libcs50-*
  4. sudo make install

默认情况下,我们安装到

/usr/local
。如果您想更改安装位置,请运行
sudo DESTDIR=/path/to/install make install
根据需要。


然后,重新编译您的程序(用

-lcs50
链接)。

如果您仍然遇到问题,请确保您使用

LD_LIBRARY_PATH
环境变量在正确的位置查找动态库。

使用上面的默认安装,执行您的程序:

$ LD_LIBRARY_PATH=/usr/local/lib ./hours

如果您使用不同的路径安装,即您使用上面的

DESTDIR
,则为
LD_LIBRARY_PATH
指定该路径。

© www.soinside.com 2019 - 2024. All rights reserved.