Closed nixoletas closed 4 years ago
After installing the library through the "sudo make install" command in the downloaded cs50 library folder...
// go to /usr/local/lib directory in Terminal
// list the contents of lib/ directory
// notice that 'libcs50.dylib' file is pointing to 'libcs50-9.dylib' file (this file does not exist)
// change the symbolic link so that 'libcs50.dylib' points to 'libcs50-9.0.1.dylib'
// type 'sudo ln -sf libcs50-9.0.1.dylib /usr/local/lib/libcs50.dylib' command and press enter
// enter macOS password
// check by listing the contents of lib/ directory if the symbolic link has changed
// go to the directory where the source code file requiring cs50 library is saved
// run 'clang -lcs50 program-to-be-compiled.c' command
// if the syntax is correct; it will create 'a.out' file
// run './a.out' command to see the output
Configure make command to be used with -lcs50 command. It can be done by creating a file called "Makefile" in the directory where the source code file is saved.
We can add the following code in the Makefile to configure make utility to work with -lcs50 command.
LDLIBS += -lcs50
CC := clang
I got the same issue, and resolved after nixoletas did! Create a file name Makefile, and added like him. Thank you, nixoletas!
I don't know if the comments in nixoletas were necessary but they sure confused me a little. However what worked was the 2nd part of the same post.
LDLIBS += -lcs50
CC := clang
Thereafter your make command should run just fine. also if your vs code has been opened before; you should also restart your vscode.
Don't have to be so hard. In your terminal, put "clang -lcs50 program-to-be-compiled.c" before, put "make program-to-be-compiled". It works for me. But you ofc have to install that cs50 library first. Dam it, why it has to be so hard for non-harved learner to do anything.
Just follow the course instructions and use this online environment by the conductor: https://cs50.harvard.edu/college/2021/fall/psets/1/hello/
LDLIBS += -lcs50 CC := clang
Thank you!
The makefile helped me.
Adding the following to .bashrc may have also helped.
export LIBRARY_PATH=/usr/local/lib
There's some discrepancy between zsh and bash.
Still having problems with Undefined symbols for architecture arm64: "_get_string", referenced from: _main in week1-18fd68.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation).
I followed and switched the libcs50.dylib -> libcs50-11.0.1.dylib
And also added
LDLIBS += -lcs50
CC := clang
to Makefile and still not showing the way it is shown on the lecture screen.
can anyone help me?
@HoonyHoney-91 this worked for me:
clang -lcs50 -o <programname> <programname>.c
David explains it in lecture 2.
I don't think it solves the issue. Although it works using your suggestion, it fails using make, giving the error @HoonyHoney-91 points out. I'm having the same issue as him.
Just like @sozoalvin said,
touch Makefile
in your current working directory and write in Makefile,
LDLIBS += -lcs50
CC := clang
and command,
make <filename>
and it will be compiled well.
Simply create a Makefile file
enter:
LDLIBS += -lcs50
CC := clang
and just do
make hello.c
Installed the library and wanted to use it with VSCODE, i'm running on a macbook pro 2015. I get this error when trying to compile with "make hello":
The library only works when compiling with "clang -lcs50 hello.c":
After that, i tried to compile my other project named "credit" and ran into this issue: