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
我尝试运行我编写的一个简单程序,但它无法编译。
您需要安装和/或找到它正在寻找的动态库:libcs50
在 mac OS 上安装的说明是(从README.md复制):
libcs50-*.*
cd libcs50-*
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
指定该路径。)