Strange problem with libc: undefined reference to `crypt'

Solution 1:

Try adding '-lcrypt' after any objects used in linking; I've had a couple of instances where gcc would complain about crypt if -lcrypt wasn't near the end of the link list.

In other words, try something like:

gcc -D FOO -D BAR -W -Wall -pedantic -O2 foo.o bar.o -lnsl -lcrypt -o baz

as opposed to

gcc -D FOO -D BAR -W -Wall -pedantic -O2 -lnsl -lcrypt foo.o baz.o -o baz

Solution 2:

undefined reference to 'crypt' is a linker error.

Try linking with -lcrypt : gcc ....-lcrypt