Search code examples
c++cencryptioncrypt

Trouble linking crypt in c++ project


I'm trying to use the crypt() method included in the GNU C library crypt. I've looked at these similar questions, 1, 2, 3 but couldn't get any of the solutions offered to work.

I'm simply including these two things

#include <unistd.h>
#include <crypt.h>

and the compiler is telling me

hashtable.h:7:19: error: crypt.h: No such file or directory
make: *** [pass.x] Error 1

How can I get the compiler to recognize crypt.h?


Solution

  • Do you have crypt installed on your system? If yes, find the directory with crypt.h and add it to compilers' headers search path: -I/path/to/crypt/headers

    You wil also need to link to the crypt lib with -lcrypt , possibly telling the linker where the lib is with -L option.

    Instruction on using crypt on OSX: Using crypt_r on OS X