Linux GCC compilation error: “collect2: LD returned 1 exit status”

bmeta_info.cpp:4280: undefined reference to ‘crypt’
collect2: ld returned 1 exit status
Information found online shows:

Undefined reference to error: this type of error is in the process of connection, there may be two reasons: one is the user to define a function or global variable in a source code file that is not compile, link, or simply has not been defined, it requires the user to modify source program according to the practical situation, presents the definition of a global variable or function body; The second is that the undefined symbol is a standard library function, which is used in the source program, and the corresponding library name is not given during the connection process, or the directory name of the archive has a problem

Use the Man crypt command to find the following information:

GNU EXTENSION
       The glibc2 version of this function has the following additional features.  If salt is a character string starting with the three characters "$1$" followed by at most eight characters, and optionally terminated by "$", then instead of using  the  DES  machine, the  glibc crypt function uses an MD5-based algorithm, and outputs up to 34 bytes, namely "$1$<string>$", where "<string>" stands for the up to 8 characters following "$1$" in the salt, followed by 22 bytes chosen from the set [a–zA–Z0–9./].  The entire key is significant here (instead of only the first 8 bytes).
       Programs using this function must be linked with -lcrypt.

Program using this function must be linked with -lcrypt. The program must be linked with -lcrypt
Reference: [http://blog.sina.com.cn/s/blog_64c238860100wzoo.html]


Read More: