Subject: Re: mingw cross compilation

Re: mingw cross compilation

From: Peter Stuge <peter_at_stuge.se>
Date: Thu, 17 Jun 2010 01:21:28 +0200

Simon Josefsson wrote:
> > I was following some posts I found on the list archives about building
> > libssh2 for win32 from linux.
>
> My Windows builds are built this way, and it has worked fine for many
> releases. My makefile is available from:
>
> http://josefsson.org/gnutls4win/Makefile
>
> It uses libgcrypt though, not OpenSSL.

I've also cross-compiled for Windows, and I tried OpenSSL first but
it did not work immediately, so I switched to using libgpg-error and
libgcrypt:

libgpg-error-1.7 in /home/stuge/w32/libgcrypt/libgpg-error-1.7:

./configure --prefix=/home/stuge/w32/libgcrypt --host=i686-mingw32

libgcrypt-1.4.5 in /home/stuge/w32/libgcrypt/libgcrypt-1.4.5:

./configure --prefix=/home/stuge/w32/libgcrypt --host=i686-mingw32 \
--enable-ciphers=aes --enable-pubkey-ciphers=dsa,rsa \
--enable-digests=sha1,sha256,sha512 \
--with-gpg-error-prefix=/home/stuge/w32/libgcrypt --without-pth-prefix

libssh2.git commit 334924ed3430e5ad642d45009283c4d1cfa91ebd in
/home/stuge/w32/libssh2/libssh2.git:

./configure --prefix=/home/stuge/w32/libssh2 --host=i686-mingw32 \
--disable-rpath --enable-debug \
--with-libgcrypt-prefix=/home/stuge/w32/libgcrypt --without-libz

zlib could of course also be built and enabled in libssh2.

I excluded most algorithms from libgcrypt to keep size down, and that
required me to fix some assumptions in libssh2.

This configuration builds static and dynamic programs without
problems, e.g. the direct_tcpip.c example in /home/stuge/w32/ls2:

dyn-direct_tcpip.exe: direct_tcpip.c
        i686-mingw32-gcc -I../libssh2/include -o $@ $< -L../libssh2/lib -L../libgcrypt/lib -lssh2 -lws2_32
        i686-mingw32-strip $@

static-direct_tcpip.exe: direct_tcpip.c
        i686-mingw32-gcc -static -I../libssh2/include -o $@ $< -L../libssh2/lib -L../libgcrypt/lib -lssh2 -lws2_32 -lgcrypt -lgpg-error
        i686-mingw32-strip $@

$ ls -l *tcpip.exe
-rwxr-xr-x 1 stuge stuge 9216 Jan 30 00:47 dyn-direct_tcpip.exe
-rwxr-xr-x 1 stuge stuge 400384 Jan 30 00:47 static-direct_tcpip.exe

Before strip the static exe is about 1.6MB.

> > I think some how I need a "cross libtool" or maybe tell libtool
> > what I'm doing.
>
> Libtool should work fine for cross-compilation if the environment
> is sane.

Yes.

> Put /opt/crosscompilers/win32/bin/ in your PATH instead, and remove
> the CC= parameter.

Strongly agree.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-06-17