Help installing Harvard CS50 library

Hello, I am taking the Harvard CS50 class and they use this C library: libcs50. There is a pull request to make it install on FreeBSD, but the install fails, I tried to see if I could make it work but it's way above my pay-grade. Could anyone help please ?
 
Builds fine for me.

I have attached the small port files but please note that the some files dont land where they should putting files just to /src looks wrong for me. I only have setup this quckly.

Aslong it works for you and you can remove it cleanly using pkg remove libcs50 everything should be fine then.

BTW, i would never try to build something outside the buildsystem / without using ports, they do often install stuff somewhere where it not should be and you cant control easily.

Code:
gmake[1]: Entering directory '/usr/home/Alexander88207/libcs50/work/libcs50-10.1.1'
cc -Wall -Wextra -Werror -pedantic -std=c11 -fPIC -shared -Wl,-soname,libcs50.so.10.1.1 -o libcs50.so.10.1.1 src/cs50.c
cc -Wall -Wextra -Werror -pedantic -std=c11 -c -o libcs50.o src/cs50.c
ar rcs libcs50.a libcs50.o
chmod 644 libcs50.a
rm -f libcs50.o
ln -sf libcs50.so.10.1.1 libcs50.so
mkdir -p build/include build/lib build/src
install -m 644 src/cs50.c build/src
install -m 644 src/cs50.h build/include
mv libcs50.so.10.1.1 libcs50.so libcs50.a build/lib
cc -Wall -Wextra -Werror -pedantic -std=c11 -fPIC -shared -Wl,-soname,libcs50.so.10.1.1 -o libcs50.so.10.1.1 src/cs50.c
cc -Wall -Wextra -Werror -pedantic -std=c11 -c -o libcs50.o src/cs50.c
ar rcs libcs50.a libcs50.o
chmod 644 libcs50.a
rm -f libcs50.o
ln -sf libcs50.so.10.1.1 libcs50.so
mkdir -p build/include build/lib build/src
install -m 644 src/cs50.c build/src
install -m 644 src/cs50.h build/include
mv libcs50.so.10.1.1 libcs50.so libcs50.a build/lib
mkdir -p /usr/home/Alexander88207/libcs50/work/stage/src /usr/home/Alexander88207/libcs50/work/stage/lib /usr/home/Alexander88207/libcs50/work/stage/include /usr/home/Alexander88207/libcs50/work/stage/share/man/man3
cp -R build/include build/lib build/src /usr/home/Alexander88207/libcs50/work/stage
cp -R docs/get_char.3.gz docs/get_double.3.gz docs/get_float.3.gz docs/get_int.3.gz docs/get_long.3.gz docs/get_long_long.3.gz docs/get_string.3.gz /usr/home/Alexander88207/libcs50/work/stage/share/man/man3
gmake[1]: Leaving directory '/usr/home/Alexander88207/libcs50/work/libcs50-10.1.1'
 

Attachments

  • libcs50.zip
    2 KB · Views: 152
Thank you very much ! I will try this ASAP !

Edit: I installed it, and it goes in the wrong path as you mentionned and it did not work, I could remove it with pkg, I'm going to study Makefile and see what I can do, thanks again
 
Sorry for OT, but, this library makes me shudder.

Most horrible thing: typedef char *string. This gives the illusion of an actual string type, of which you'd assume it would hold a string value, although it still just holds a pointer(!) to an array of characters.
IMHO: Never ever hide a pointer behind a typedef.

And then, this get_string() function, well … best thing you can say about it is that it doesn't seem to have critical bugs. But why is it setting output non-buffered, and why does it call realloc() for each and every character entered, and WHY do you have to keep every string on the heap until the end of the program, etc…? :eek:

I don't know that course, maybe it isn't bad after all, but these fishy things in the library kind of disturb me.

So, the goal of the library simply is to "solve" the problem of user input before you understand how the I/O streams actually work in C. Maybe that's not the worst idea; it's better than some other courses just teaching to get user input with scanf() (which is really a recipe for shooting yourself in the foot). But sooner or later (IMHO better sooner) you should understand how to do these things with standard C. For anyone interested, I wrote a few words on the topic a few years ago: http://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html
 
Back
Top