How to install custom c library?
Posted
by
arijit
on Ask Ubuntu
See other posts from Ask Ubuntu
or by arijit
Published on 2012-03-10T11:27:35Z
Indexed on
2012/11/25
5:18 UTC
Read the original article
Hit count: 284
I just wanted to add a c library to Ubuntu which was created by Harvard University for cs50 course. They provided instructions for how to install the library which is listed below.
Debian, Ubuntu
First become root, as with:
sudo su -
Then install the CS50 Library as follows:
apt-get install gcc
wget http://mirror.cs50.net/library/c/cs50-library-c-3.1.zip
unzip cs50-library-c-3.1.zip
rm -f cs50-library-c-3.1.zip
cd cs50-library-c-3.1
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 cs50-library-c-3.1
I did exactly as directed. But the compiler reported “Undefined reference to a function”--the function was Get String. So, I searched for a solution and found one. It said to use the -l
switch.
Now when I compile I use something like:
gcc –o hello.c hello –lcs50
(I don’t remember the exact command.)
However, I cannot use the make
command, which is easier to use.
I understand that there is some problem with linking the library. What is a good solution to this problem?
© Ask Ubuntu or respective owner