title: gcc -lcrypt flag error in UNIX C - Undefined Reference to crypt()
body: <p>I use <code>crypt()</code> function and the compile flag named <code>-lcrypt</code> the problem is that the compiler says undefined reference to <code>crypt()</code>. Can anyone tell me what I'm doing wrong?</p>
  
  <p><strong>Makefile</strong></p>
  
  <pre><code>    CC = gcc
      CFLAGS=-Wall -lm -lcrypt
      OBJS = get_passwords_hashed.o
      PROG = get_passwords_hashed.exe
  
      #adicionar or mudar o OBJS se tiver outras files para o programa
  
  
      #GENERIC
  
      all:    ${PROG}
  
      clean:
              rm ${OBJS} *~ ${PROG}
  
      ${PROG}: ${OBJS}
              ${CC} ${OBJS} -o $@
  
      .c.o:
              ${CC} $&lt; -c -o $@
      # $@ - turns .c into .o 
      ###################################
      #dependencias
      so_final.o: get_passwords_hashed.c get_passwords_hashed.h
  </code></pre>
  
  <p><strong>main.c</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;crypt.h&gt;
  
  int testar_pass(char ant[],char (*pointer_hashes)[max_chars_string]){ // ponteiro para array de chars - char ** ant
       char * password ;
       char * encrypted;
       password = malloc(strlen(ant)*sizeof(char)); //password calculada recebida anteriror
       encrypted = malloc(strlen(ant)*sizeof(char));//hash
       strcpy(password,ant);
       encrypted = crypt(password,"10");
       if(strcmp(*pointer_hashes,encrypted) == 0){
           return 1;
           }
       else return 0;// devolve erro
  }
  </code></pre>