libcs50
v11.0.3
make
:构建动态库
make deb
:构建源 deb
make install
:默认将库安装在/usr/local
下(设置DESTDIR
进行更改)
$ curl -s https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | sudo bash
$ sudo apt-get install libcs50
$ curl -s https://packagecloud.io/install/repositories/cs50/repo/script.rpm.sh | sudo bash
$ yum install libcs50
libcs50-*.*
cd libcs50-*
sudo make install
默认情况下,我们安装到/usr/local
。如果您想更改安装位置,请根据需要运行sudo DESTDIR=/path/to/install make install
。
/usr/bin/ld: cannot find -lcs50
:将export LIBRARY_PATH=/usr/local/lib
添加到.bashrc
中。fatal error: 'cs50.h' file not found
:将export C_INCLUDE_PATH=/usr/local/include
添加到.bashrc
中。error while loading shared libraries: libcs50.so.8: cannot open shared object file: No such file or directory
:将export LD_LIBRARY_PATH=/usr/local/lib
添加到您的.bashrc
。关闭并重新打开所有终端窗口。
与-lcs50
链接。
#include <cs50.h>
...
char c = get_char("Prompt: ");
double d = get_double("Prompt: ");
float f = get_float("Prompt: ");
int i = get_int("Prompt: ");
long l = get_long("Prompt: ");
string s = get_string("Prompt: ");
// deprecated as of fall 2017
long long ll = get_long_long("Prompt: ");
安装后参见man get_*
,或 CS50 参考!