This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: crypt() usage


You have to tell gcc where the library that implements crypt is, not just
the header file. Also the man page for crypt says you have to define
_XOPEN_SOURCE. try:
	gcc code.c -lcrypt -D_XOPEN_SOURCE 

PS, man pages are viewable on the net just do a search or try
http://linux.ctyme.com/ 

cheers
	jackson

                          _______
#********************#   / _____ \
# D. Jackson Peacock #  / /_____\ \
# pavon@gallup.net   #  |___   __ |
# ICQ 25755468       #      | |_/ /
# PO Box 2102        #      |  __/  
# Socorro, NM 87801  #  --__/ /
#********************#  \____/


On Tue, 11 Jul 2000, ASe User wrote:

> Hi,
> I'm running in a shell in FreeBSD 3.2 and using GCC to write CGI scripts.  I'm trying to use crypt() in the following program 
> $ cat systest.c
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> #include <ctype.h>
> #include <unistd.h>
> #include <des.h>
> 
> //#include <io.h>
> 
> void main()
> {
>         char *cryptpass;
>         strcpy(cryptpass,crypt("firstpas","as"));
> }
> 
> and getting the error:
> 
> $ gcc -g systest.c
> /var/tmp/ccm266661.o: In function `main':
> /www/cgi-bin/classcgi/cgisrc/src/systest.c(.text+0x1e): undefined reference to `crypt'
> 
> My questions are:
> 1) I greped crypt and it showed up in unistd.h and des.h.  Are there other headers that I should include?  How do I get it referenced?
> 2) What is the correct usage for crypt?  [Eg. Char *crypt(char *pass, char *salt)] Do you have an example in c?
> 
> This info could probably come from man but that is disabled in my shell.  Is there a gcc library reference available on the web?
> 
> Thanks and regards,
> Wes
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]