setevoy
setevoy

Reputation: 4662

Building FTP4ALL: undefined reference to `crypt'

I know - there is a lot of question like this one - but can't find solution...

Trying to install FTP4ALL 3.012 on CentOS 6.

/configure executed normally, but make - returns me error:

f4adp_user.o: In function `f4adp_usr_pwd':
f4adp_user.c:(.text+0xfa0): undefined reference to `crypt'
f4adp_user.o: In function `f4adp_usr_chg':
f4adp_user.c:(.text+0x340e): undefined reference to `crypt'
f4adp_user.o: In function `f4adp_usr_adq':
f4adp_user.c:(.text+0x37a7): undefined reference to `crypt'
serverd.o: In function `user_request_login_permission':
serverd.c:(.text+0x2a9a): undefined reference to `crypt'
collect2: ld returned 1 exit status

Makefile contains only:

$ cat Makefile | tail -n 15
all:
    @cd src ; make

strip:
    @cd src ; make strip

clean:
    @cd lib ; make clean
    @cd src ; make clean
    @cd cfg ; make clean
    @rm -f Makefile src/common/tweak.h src/common/Makefile src/Makefile src/ftpa/Makefile src/ftpd/Makefile src/ftps/Makefile

install:
    cp -f bin/* /usr/local/bin

How can I fix it?

Upvotes: 0

Views: 1370

Answers (2)

setevoy
setevoy

Reputation: 4662

Regarding FTP4ALL only - solution is:

$ vim ../../ftp/ftp4all/configure

where ftp4all is directory, which was created after:

$ tar xfp ftpd-3.012.tar.gz`

Find lines:

echo $ac_n "| want DES encryption (y/n) ? $ac_c"

Edit:

else
  DES=""
  LIB=${LIB}
fi

To:

else
  DES=""
  LIB=${LIB}" -lcrypt"
fi

Also, after this - I got another error when compile:

common.c:52: error: conflicting types for ‘setenv’
/usr/include/stdlib.h:585: note: previous declaration of ‘setenv’ was here

Solution:

$ vim ./src/ftps/common.c

Comment with /* and */ lines:

#ifndef HAVE_SETENV
/*
void setenv(char* var, char* val, int new)
{ char str[256];

  sprintf(str,"%s=%s",var,val);
  putenv(str);
}
*/

#endif /* HAVE_SETENV */

Now - it works.

P.S. Please note, that:

FTP4ALL is no longer maintained. This web site is only for historic purposes. Visit the successor project OpenFTPD instead.

Hope - nobody else will try install it :-)

Upvotes: 0

razeh
razeh

Reputation: 2765

You need to add -lcrypt to your link line so the linker will search the crypt for the crypt function.

In normal Unix tool chains, things flow like this:

Source code (compiler) -> assembly code (assembler) -> .o files -> (linker) -> executable.

The linker, which is the last part of the tool chain, is responsible for combining all of your functions into an executable. Somewhere in your Makefile, most likely the Makefile in your src subdirectory, there will be a line that tells the linker where to find all of the .o files, and any dependent libraries. That's you link line, and it needs to have -lcrypt so that it can find the crypt function.

Upvotes: 1

Related Questions