1

I'm just starting out, using VS code as my IDE. Here is my code

#include <stdio.h>

//here were are setting up a function
//meow(void) means it takes no arguments
//void at the beginning is specifying the return type
void meow(void)
{
    printf("meow\n");
}

int main(void)
{
    for (int i = 0; i <3 ; i++)
    {
        meow();
    }
}

And here is the error I receive after typing make meow in the terminal :

clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow    meow.c  -lcrypt -lcs50 -lm -o meow
ld: library not found for -lcrypt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [meow] Error 1

Importantly, in accordance with this source from the cs50 course https://cs50.readthedocs.io/libraries/cs50/c/, my .bashrc file looks like this:

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

And for what it's worth, my .bash_profile looks like this:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/cam/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/cam/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/cam/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/cam/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
export CC="clang"
export CFLAGS="-fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow"
export LDLIBS="-lcrypt -lcs50 -lm"

Also, the program will compile if I run clang meow.c. That creates an object called a.out and then if I run ./a.out the meow program will run. So I guess the problem the problem is with make. Perhaps it's not finding the clang compiler for some reason?

Or perhaps this has something to do with not having the -lcrypt library? I've tried to find more info on this library, but couldn't find anything available. Not literature on the web or anything to download and install. Perhaps I'm overlooking something.

Any help on this error would be appreciated.

1 Answer 1

2

If you’re on mac then -lcrypt doesn’t exist separately. Neither does -lm for that matter. They’re both linked as part of the standard library.

Change LDLIBS to just -lcs50 and you should be good.

4
  • Hey, thank you very much. That worked!
    – CAM_etal
    Commented Jan 28, 2022 at 10:45
  • Perhaps one more thing...if I use another shell, say zsh, i'll have to change the .rc and _profile files for that particular shell?
    – CAM_etal
    Commented Jan 28, 2022 at 10:46
  • @CAM_etal yes, .zshenv for environment variables, at least that's the norm. You can use .zprofile if you only want that setting in an interactive shell. Commented Jan 28, 2022 at 10:48
  • OK cool. Thanks for your help :)
    – CAM_etal
    Commented Jan 28, 2022 at 10:51

You must log in to answer this question.

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