Skip to content

Can't link to libcs50 #331

@jacoboneill

Description

@jacoboneill

Running on an intel mac, after running sudo make install on the library, and compiling a basic c file:

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

int main(){
  string res = get_string("> ");
  printf("%s", res);
}

I get an error that it can't load the library libcs50-11.0.2.dylib (I run clang main.c -o ./a.out -lcs50)

dyld[67961]: Library not loaded: libcs50-11.0.2.dylib
  Referenced from: <2CE4BD41-8453-3EDB-BBF4-70AD89B6C454> /Users/jacoboneill/Programming/cs50x/01/notes/user_input/a.out
  Reason: tried: 'libcs50-11.0.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcs50-11.0.2.dylib' (no such file), 'libcs50-11.0.2.dylib' (no such file), '/Users/jacoboneill/Programming/cs50x/01/notes/user_input/libcs50-11.0.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/jacoboneill/Programming/cs50x/01/notes/user_input/libcs50-11.0.2.dylib' (no such file), '/Users/jacoboneill/Programming/cs50x/01/notes/user_input/libcs50-11.0.2.dylib' (no such file)
[1]    67961 abort      ./a.out

After trying all the troubleshooting steps (setting C_INCLUDE_PATH, LD_LIBRARY, LIBRARY_PATH) nothing seems to help. I found a hacky way by running ln -s /usr/local/lib/libcs50-11.0.2.dylib ./libcs50-11.0.2.dylib (as it said it tried to search for it in the local folder in the debug). This works but I feel as though probably not the intended way to do it.

I can't tell if I did something wrong, or if there is something wrong with libcs50's makefile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions