PDA

View Full Version : "crypt()" problem with cc


stampeding
09-12-2000, 01:30 PM
Hello, I have a "cc" problem while
trying to compile a cgi script:

"man" says this about the function
"crypt":

<manText>

NAME
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] crypt - password and data encryption

SYNOPSIS
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] #define _XOPEN_SOURCE
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] #include <unistd.h>

[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] char *crypt(const char *key, const char *salt);

</manText>

Now, my C code looks like this:

<cCode>

#define _XOPEN_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
.
.
.
[nbsp][nbsp][nbsp][nbsp]strcpy(cod,crypt(pwd,salt));

</cCode>

Still, I get this compiler error:

<errorMessage>

/tmp/cca198881.o: In function `fix_pwd':
/tmp/cca198881.o(.text+0xa0e): undefined reference to `crypt'

</errorMessage>

Why? Is some compiler option missing?

Note that it's NOT complaining that
&quot;crypt&quot; is an integer parameter in
strcpy, i.e. it's probably Ok in the
h-files.

However, it's missing while linking.

How can I fix this?

Regards,
/Stampeding[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]

Samuel
09-12-2000, 01:38 PM
It's me again (i.e. the poster
&quot;stampeding&quot; above).

I forgot to post from my real &quot;site
owner account&quot;, since it was a long
time since I posted to this forum.

/Samuel

Terra
09-12-2000, 02:01 PM
With glibc-2.x, this was split out of the core C libraries...

add, '-lcrypt' to your compiler string and it should work for you...

--
Terra
--Been snagged by one-to-many autoconf scripts not doing the right thing--
FutureQuest

Samuel
09-13-2000, 01:00 PM
Yes, that did the trick!

Thanks!

/Samuel