I'm trying to work on my C psets on my local machine in vscode. I've installed the cs50 library locally but am having trouble compiling. OS is osx 10.14.3

The error I'm receiving when compiling with either clang (or gcc) is:

mwexler-ltm2:Desktop mwexler$ clang hello.c -lcs50
ld: library not found for -lcs50
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I created a ~/.bashrc based on the readme for the library and other searching I've done, and I've restarted the terminal many times, esp after any changes to .bashrc

I also tried the .bashrc below with just both of the bottom two lines independently(one with just line 7 and one with just line 8)


# configure clang
export CC=clang
export CFLAGS="-fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow"
export LDLIBS="-lcrypt -lcs50 -lm"

export LIBRARY_PATH=/usr/local/lib
export C_INCLUDE_PATH=/usr/local/include


eval "$(rbenv init -)"
if [ -f ~/.bashrc ]; then
   source ~/.bashrc

Lastly, I do see what looks to be the right library files in usr/local/lib:


For completeness, my .c file hello.c is extremely basic:

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

int main(void)
    int i = get_int("what is a number: ");

The other issue is that the make command doesnt append the -lcs50 and therefore errors for a different reason, but I can live without that for now :)

Logically, I think this makes sense. The .bash_profile indicates that there's a .bashrc to reference. The .bashrc indicates the explicit path to find the library, and the argument to include that library is passed into clang. But it's still not finding the library. New to all of this and am much less familiar with the interaction of those files.

Any help is much appreciated!


I checked github and was able to make it work. Maybe you should post your question there too. Good luck!

| improve this answer | |

You must log in to answer this question.

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