I don't access to 4g internet connection, so I installed cs50 library on my lubuntu for offline use, I put the cs50.h file in /usr/local/inlcude and the libcs50.a file in /usr/local/lib. Now when i use clang to compile, I get linker error. Check below attached images.

This is the code in my string.c file:

#include <stdio.h>
#include <cs50.h>

int main(void) {
        string answer = get_string("What's your name?\n");
        printf("hello, %s", answer);}

Error displayed while compiling

1 Answer 1


The library interface (cs50.h) and the implementation (cs50.c) needs to be compiled into either a library object file (.o), a shared object file (.so), or an archive file (.a) in order to be linked into other programs.

The following command should yield an object file that could be statically linked it into other programs assuming both cs50.h and cs50.c are present in the current working directory.

cc -c -o cs50.o cs50.c

The resulting object file (cs50.o) should then be placed ideally under /usr/local/lib/ while the implementation file (cs50.h) should be placed under /usr/local/include/ with 644 permission preferably.

Alternately, following the instructions outlined at cs50/libcs50 will yield an equivalent denouement but with relatively less complication.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .