Is there any way I can download and install the CS50 library to my system and run programs importing the library instead of downloading the virtual machine ?
Here are the instructions for installing CS50 library in your OS:
First become root, as with:
su - // Fedora, RedHat, CentOS sudo -s // Debian, Ubuntu, Mint //edited from sudo su -, use sudo -s on Ubuntu.
Then install the CS50 Library as follows:
yum -y install gcc // Fedora, RedHat, CentOS apt-get install gcc // Debian, Ubuntu, Mint wget http://mirror.cs50.net/library50/c/library50-c-5.zip unzip library50-c-5.zip rm -f library50-c-5.zip cd library50-c-5 gcc -c -ggdb -std=c99 cs50.c -o cs50.o ar rcs libcs50.a cs50.o chmod 0644 cs50.h libcs50.a mkdir -p /usr/local/include chmod 0755 /usr/local/include mv -f cs50.h /usr/local/include mkdir -p /usr/local/lib chmod 0755 /usr/local/lib mv -f libcs50.a /usr/local/lib cd .. rm -rf library50-c-5
For those lucky fellows running Linux, there's this reddit explaining how to make Linux Mint "CS50 compatible" (i.e.: installing
check50, and cs50 libraries for
Download and install Xcode.
Download and unzip library50-c-5.zip.
Open Applications > Utilities > Terminal, and navigate your way to the CS50 Library’s directory, as with cd.
Execute the commands below, entering your password if prompted:
gcc -c -ggdb -std=c99 cs50.c -o cs50.o ar rcs libcs50.a cs50.o rm -f cs50.o chmod 0644 cs50.h libcs50.a sudo mkdir -p /usr/local/include sudo mv -f cs50.h /usr/local/include sudo mkdir -p /usr/local/lib sudo mv -f libcs50.a /usr/local/lib cd .. rm -rf library50-c-5
It depends on your compiler, but odds are the simplest method of installation is to:
Download and unzip
cs50.hinto the same directory as your own code.
After installing the CS50 Library, you can include its header file atop your own code with:
Note the use of quotes instead of angled brackets.
An easier method is to use my CS50 tools setup if you're on Ubuntu or Fedora. Open a terminal in your download directory, and run
sudo sh cs50_setup_ubuntu.sh
sudo sh cs50_setup_fedora.sh
depending which OS you're on
Download the file here:
Ubuntu (and Ubuntu derivative, such as Linux Mint etc): https://www.dropbox.com/s/6wv06ejnw7ryqf6/cs50_setup_ubuntu.sh?dl=0
Fedora (and Fedora derivative, such as Red Hat etc): https://www.dropbox.com/s/qn3dedqznxem9vt/cs50_setup_fedora.sh?dl=0
to compile the program and
to check it.
Here's a video for adding the CS50 library for Codeblocks IDE in Windows It's similar to one @abelinux mentioned but sets it up for all projects instead of having to add it individually to each project: CS50 Library on Windows CodeBlocks IDE
There's also a small gotcha with the get_string method which it helps sidestep if you are facing issues with improper arguments or too few arguments error when trying to use it.
If using Linux and you want to install the CS50 Library from source, follow these steps:
- Go to https://github.com/cs50/libcs50/releases
- Download the latest release of the library (file that ends in .tar.gz)
- Navigate to downloaded file
- Extract the contents to a folder
- Navigate to the above folder
sudo make install
That is all. Worked well for me.