libssh2

1. Get the source
Get libssh2 from www.libssh2.org (I got libssh2-1.1.tar.gz)
Get gnupgp from http://www.gnupg.org/ ( I got gnupg-1.4.9)
Get libgcrypt from http://www.gnupg.org (I got libgcrypt-1.4.4)
Get libpgp-error from http://www.gnupg.org (I got libgpg-error-1.7)

ZLib is provided by Apple in the SDK.
If you still want to build it from the source (zlib-1.2.3),
your environement should be
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.0.sdk
export CC=$DEVROOT/usr/bin/gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/g++
unset AR
unset AS
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -L/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/lib"
export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/include"
export CXXFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/include/"

and the configure :
./configure --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os

2. Extract sources

3. Build gnupgp
My compile_environ file:
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.0.sdk
export CC=$DEVROOT/usr/bin/gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/g++
export AR=$DEVROOT/usr/bin/ar
export AS=$DEVROOT/usr/bin/as
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -L/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/lib"
export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/include"
export CXXFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os"

(Refer to ZBar to understand compile_environ)

Then the configure:
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os

Make and make install

4. Build libgpg-error
Use the same compile_environ

Then the configure:
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --enable-shared=no

Then make and make install

5. Build libgcrypt
Use the same compile_environ

Then the configure:
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --enable-shared=no --with-gpg-error-prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os

Then make and make install

6. Build libssh2
Use the same compile_environ

Configure:
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --with-libgcrypt-prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os


7. Use it in your iphone application
I did not use it in one of my application but I think you will need to include the following as framework:
  • libssh2.a
  • libgpg-error.a
  • libgcrypt.a
  • libz.a

Comments