Trouble linking program with -lcrypt

Using Slackware 64 14.1 (kernel 3.10.17), and Slackware 13.37.0 (kernel

Any idea why I can't get the following to link? It work on a version older than 13.37 - or I built it differently back in 2005. Now, I can't get it to link with either of these versions of Slackware

I'm doing `make crypt -lcrypt` and get:

$ make crypt -lcrypt
cc   crypt.o   -o crypt
crypt.o: In function `main':
crypt.c:(.text+0x3b): undefined reference to `crypt'
collect2: error: ld returned 1 exit status
make: *** [crypt] Error 1
#include <string.h>
#include <unistd.h>
#include <stdio.h>

main(int argc, char *argv[])

    if ((argc > 1) && strlen(argv[1]))
        printf("%s\n", crypt(argv[1], "MF") + 2);

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
Your Makefile should contain something like the following target:

<tab>gcc crypt.c -o crypt -lcrypt

Open in new window

Note: <tab> MUST be a tab character - it cannot be just white space!

You can't just pass the linker arguments direct to make like that, they need to be passed to the compiler/linker as part of the Makefile.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarkAuthor Commented:
Yup! That did the trick. Actually I just used `gcc crypt.c -o crypt -lcrypt` on the command line.

I knew all this once. It's been too long since I've done C!!!
evilrixSenior Software Engineer (Avast)Commented:
Glad to have been able to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.