Followed many tutorials so far and had various error. Below is the complete step by step procedure that i followed and ended up having errors with OpenSSH compilation.
Downloaded Zlib and cross compiled ($HOME/Desktop/Zlib/zlib-1.2.5/output)
cd /home/armsdk/Desktop/
mkdir zlib
cd Zlib
wget http://www.zlib.net/fossils/zlib-1.2.5.tar.gz
tar xzvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
mkdir output
./configure --prefix=/home/armsdk/Desktop/Zlib/zlib-1.2.5/output CC=arm-cortexa9-linux-gnueabi-gcc
make
make install
Downloaded OpenSSL and cross compiled : ($HOME/Desktop/OpenSSL/OpenSSL_CC)
mkdir OpenSSL
cd OpenSSL
wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
tar xzvf openssl-1.0.1g.tar.gz
cd openssl-1.0.1g/
export cross=arm-cortexa9-linux-gnueabi-
./Configure dist --prefix=$HOME/Desktop/OpenSSL/OpenSSL_CC
make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"
make install
Cross Compiled OpenSSH :
./configure --prefix=$HOME/Desktop/OpenSSH/OpenSSH_CC --host=arm --with-libs --with-zlib=$HOME/Desktop/Zlib/zlib-1.2.5/output --with-ssl-dir=$HOME/Desktop/OpenSSL/OpenSSL_CC --disable-etc-default-login CC=arm-cortexa9-linux-gnueabi-gcc AR=arm-cortexa9-linux-gnueabi-ar
make
GETTING CRYPT ERROR:
openbsd-compat//libopenbsd-compat.a(xcrypt.o): In function `xcrypt':
/home/armsdk/Desktop/OpenSSH/openssh-5.2p1/openbsd-compat/xcrypt.c:78: undefined reference to `crypt'
collect2: error: ld returned 1 exit status
Please help me resolve. All i need is SFTP-Server for remote debugging using gdbServer (via Eclipse)
Compiling on system running : Debian Wheezy
Target Board : Ka-Ro TX6S
Target Processor : NXP i.MX6S7
Host Linux version : 3.16.0-0.bpo.4-amd64
Target Linux Version : 4.4.0-00118-g26d6b51
CrossCompiler : gcc-arm-cortexa9-linux-gnueabi
Update 1:
Adding the below line Gave error:
-I/home/armsdk/Desktop/OpenSSL/OpenSSL_CC/include
Error
configure: error: unrecognized option: -I/home/armsdk/Desktop/OpenSSL/OpenSSL_CC/include
Tried this instead but the CRYPT error still exists.
--includedir=/home/armsdk/Desktop/OpenSSL/OpenSSL_CC/include
Update 2:
Tried -lcrypt flag as suggested here : undefined reference to `crypt' But this doesnt have any change in error.
make clean
make -lcrypt
Update 3: Added 'CFLAGS=-lcrypt' and the error now changed
./configure --prefix=$HOME/Desktop/OpenSSH/OpenSSH_CC --host=arm --with-libs --with-zlib=$HOME/Desktop/Zlib/zlib-1.2.5/output --with-ssl-dir=$HOME/Desktop/OpenSSL/OpenSSL_CC --disable-etc-default-login CC=arm-cortexa9-linux-gnueabi-gcc AR=arm-cortexa9-linux-gnueabi-ar CFLAGS=-lcrypt
Error
openbsd-compat//libopenbsd-compat.a(xcrypt.o): In function `xcrypt':
xcrypt.c:(.text+0x2c): undefined reference to `crypt'
collect2: error: ld returned 1 exit status
make: *** [sshd] Error 1
Update 4: Updated the LDFLAGS and CFLAGS as below:
./configure --prefix=$HOME/Desktop/OpenSSH/OpenSSH_CC --host=arm --with-libs --with-zlib=$HOME/Desktop/Zlib/zlib-1.2.5/output --with-ssl-dir=$HOME/Desktop/OpenSSL/OpenSSL_CC --disable-etc-default-login CC=arm-cortexa9-linux-gnueabi-gcc AR=arm-cortexa9-linux-gnueabi-ar LDFLAGS=-L/home/cross-gcc-4.9.1-2.19-18-armv7a-soft/x86_64-pc-linux-gnu/arm-cortexa9-linux-gnueabi/sys-root/lib CFLAGS=-lcrypt
Issue is still the same:
openbsd-compat//libopenbsd-compat.a(xcrypt.o): In function `xcrypt':
xcrypt.c:(.text+0x2c): undefined reference to `crypt'
collect2: error: ld returned 1 exit status
make: *** [sshd] Error 1
Update 5:
I finally got it to successfully 'MAKE'but not able to 'make install'
./configure --prefix=$HOME/Desktop/OpenSSH/OpenSSH_CC --host=arm --with-libs --with-zlib=$HOME/Desktop/Zlib/zlib-1.2.5/output --with-ssl-dir=$HOME/Desktop/OpenSSL/OpenSSL_CC --disable-etc-default-login CC=arm-cortexa9-linux-gnueabi-gcc AR=arm-cortexa9-linux-gnueabi-ar LDFLAGS='-L/home/cross-gcc-4.9.1-2.19-18-armv7a-soft/x86_64-pc-linux-gnu/arm-cortexa9-linux-gnueabi/sys-root/lib -lcrypt'
make
make install
Error when 'make install'
(umask 022 ; ./mkinstalldirs /var/empty)
/usr/bin/install -c -m 0755 -s ssh /home/armsdk/Desktop/OpenSSH/OpenSSH_CC/bin/ssh
strip: Unable to recognise the format of the input file `/home/armsdk/Desktop/OpenSSH/OpenSSH_CC/bin/ssh'
/usr/bin/install: strip process terminated
Update 6 : Hopefully Final
So i finally am able to generate the outputs by adding the flag '--disable-strip'
./configure --prefix=$HOME/Desktop/OpenSSH/OpenSSH_CC --host=arm --disable-strip --with-libs --with-zlib=$HOME/Desktop/Zlib/zlib-1.2.5/output --with-ssl-dir=$HOME/Desktop/OpenSSL/OpenSSL_CC --disable-etc-default-login CC=arm-cortexa9-linux-gnueabi-gcc AR=arm-cortexa9-linux-gnueabi-ar LDFLAGS='-L/home/cross-gcc-4.9.1-2.19-18-armv7a-soft/x86_64-pc-linux-gnu/arm-cortexa9-linux-gnueabi/sys-root/lib -lcrypt'
make
make install
One small issue though, i had this error :
mkdir /home/armsdk/Desktop/OpenSSH/OpenSSH_CC/etc
./ssh-keygen: 1: ./ssh-keygen: Syntax error: word unexpected (expecting ")")
./ssh-keygen: 1: ./ssh-keygen: Syntax error: word unexpected (expecting ")")
./ssh-keygen: 1: ./ssh-keygen: Syntax error: word unexpected (expecting ")")
make: *** [host-key] Error 2
Solution was to
Add the libcrypt path to the compiler, for some reason the compiler couldnt find the right library
LDFLAGS='-L/home/cross-gcc-4.9.1-2.19-18-armv7a-soft/x86_64-pc-linux-gnu/arm-cortexa9-linux-gnueabi/sys-root/lib -lcrypt'
Added '--disable-strip' to overcome the STRIP error with the install command
My final configure command looks like this:
./configure --prefix=$HOME/Desktop/OpenSSH/OpenSSH_CC --host=arm --disable-strip --with-libs --with-zlib=$HOME/Desktop/Zlib/zlib-1.2.5/output --with-ssl-dir=$HOME/Desktop/OpenSSL/OpenSSL_CC --disable-etc-default-login CC=arm-cortexa9-linux-gnueabi-gcc AR=arm-cortexa9-linux-gnueabi-ar LDFLAGS='-L/home/cross-gcc-4.9.1-2.19-18-armv7a-soft/x86_64-pc-linux-gnu/arm-cortexa9-linux-gnueabi/sys-root/lib -lcrypt'
make
make install
Thanks to @Jakuje, @Gaurav Pathak and @k_kaz