crypt function and link error “undefined reference to 'crypt'”

后端 未结 6 1441
别跟我提以往
别跟我提以往 2020-12-11 18:34

I have used the crypt function in c to encrypt the given string. I have written the following code,

#include
#include

int mai         


        
6条回答
  •  既然无缘
    2020-12-11 19:09

    If you want to use the crypt() function, you need to link to the library that supplies it. Add -lcrypt to your compile command.

    Older versions of glibc supplied a libcrypt library for this purpose, and declared the function in - to compile against this support, you may also need to define either _XOPEN_SOURCE or _GNU_SOURCE in your code before including .

    Newer versions of glibc don't supply libcrypt - it is instead provided by a separate libxcrypt. You still link with -lcrypt, but the function is instead declared in .

提交回复
热议问题