Thread: mingw cross-compiling libpq.dll+ssl on Debian

mingw cross-compiling libpq.dll+ssl on Debian

From
Tomasz Myrta
Date:
Hello

I've tried to recompile libpq.dll with ssl support using mingw32
cross-compiler on Debian. I would like to create single lightweight
libpq-ssl.dll instead of almost 3MB
libpq.dll+libeay32.dll+krb5_32.dll+libintl-2.dll+ssleay32.dll deployed
recently with Postgresql Windows package. My Postgresql source version
is 8.1.5. I have some success, but it's not enough.

1. Patching mingw32.
Windres is unknown application for Debian, so we need to create file
/usr/bin/windres containing:

#!/bin/sh
i586-mingw32msvc-windres -I  /usr/i586-mingw32msvc/include/ $1 $2 $3 $4
$5 $6 $7

2. Creating makefile - without ssl support for now:
export CC=i586-mingw32msvc-gcc
export LD=i586-mingw32msvc-ld
export AR=i586-mingw32msvc-ar
export NM=i586-mingw32msvc-nm
export RANLIB=i586-mingw32msvc-ranlib
export DLLTOOL=i586-mingw32msvc-dlltool
export OBJDUMP=i586-mingw32msvc-objdump
export STRIP=i586-mingw32msvc-strip
export STRIPPROG=i586-mingw32msvc-strip
export AS=i586-mingw32msvc-as
export RC=i586-mingw32msvc-windres
./configure --host=i586-mingw32msvc --without-zlib \
--prefix /usr/i586-mingw32msvc --target=i586-mingw32msvc \
export PATH=/usr/i586-mingw32msvc/bin:$PATH

3. dllwrap gives an error:
/usr/i586-mingw32msvc/bin/ld: unrecognised emulation mode: elf_i386
Supported emulations: i386pe

I've read somewhere, that dll's can be linked through gcc. Replacing
dll-tool with gcc in Makefile.shlib:
i586-mingw32msvc-gcc --strip-all -shared -DBUILDING_DLL -o $(shlib)
$(DLLTOOL_LIBFLAGS) $(OBJS) $(SHLIB_LINK)
solved the problem.

4. openssl is much easier to build:
./Configure mingw shared no-krb5
We have to replace "gcc" with "i586-mingw32msvc-gcc" in Makefile (CC=
and MAKEDEPPROG=).

After applying these patches I'm able to get:
- libpq.dll without ssl support
- ssleay32-0.9.8.dll
- cryptoeay32-0.9.8.dll

Postgresql8.1.5 configure script --with-openssl option gives me an error:
configure: error: library 'eay32' is required for OpenSSL

- I have no idea how to make openssl dll's visible to it. I suppose,
that cryptoeay32 is not expected library name.
- which openssl cyphers are really necessary to work with Postgresql ?
- when exactly is used libiconv.dll and libintl-2.dll - do I also need
them ?
- how to link all of these libraries into single libpq.dll file ?

Best regards,
Tomasz Myrta

Re: mingw cross-compiling libpq.dll+ssl on Debian

From
Peter Eisentraut
Date:
Am Freitag, 10. November 2006 00:18 schrieb Tomasz Myrta:
> - which openssl cyphers are really necessary to work with Postgresql ?

No.

> - when exactly is used libiconv.dll and libintl-2.dll - do I also need
> them ?

For national language support.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: mingw cross-compiling libpq.dll+ssl on Debian

From
Tomasz Myrta
Date:
Peter Eisentraut napisal 2006-11-10 12:44:
> Am Freitag, 10. November 2006 00:18 schrieb Tomasz Myrta:
>
>> - which openssl cyphers are really necessary to work with Postgresql ?
>>
>
> No.
>
?
The INSTALL file from openssl contains list of supported cyphers:
bf, cast, des, dh, dsa, hmac, md2, md5, mdc2, rc2, rc4, rc5, rsa, sha
I was thinking about limiting them only to necessary ones.

>
>> - when exactly is used libiconv.dll and libintl-2.dll - do I also need
>> them ?
>>
>
> For national language support
I know - /usr/bin/iconv is familiar to me.
My database is "C" locale, all sorting is client-side, I don't need
server and libpq messages other than English. Can I avoid using these 2
libraries?

Anyway - do you have some hints for recompiling libpq?

Regards,
Tomasz Myrta

Re: mingw cross-compiling libpq.dll+ssl on Debian

From
Peter Eisentraut
Date:
Tomasz Myrta wrote:
> The INSTALL file from openssl contains list of supported cyphers:
> bf, cast, des, dh, dsa, hmac, md2, md5, mdc2, rc2, rc4, rc5, rsa, sha
> I was thinking about limiting them only to necessary ones.

You don't need any if you don't want encryption.

> My database is "C" locale, all sorting is client-side, I don't need
> server and libpq messages other than English. Can I avoid using these
> 2 libraries?

NLS is only used if you enable it explicitly.  So don't do that.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: mingw cross-compiling libpq.dll+ssl on Debian

From
Tomasz Myrta
Date:
Tomasz Myrta napisal 2006-11-10 00:18:
> Postgresql8.1.5 configure script --with-openssl option gives me an error:
> configure: error: library 'eay32' is required for OpenSSL
The solution was very near.

Postgresql's configure script doesn't like original OpenSSL dll names.
We have to create symbolic links:
eay32.dll -> cryptoeay32-0.9.8.dll
ssleay32.dll -> ssleay32-0.9.8.dll

After this - libpq.dll is built as expected. Now, I have to remove
unnecessary cyphers from rather big cryptoeay32-0.9.8.dll and try to
link these files into single libpq.dll.

Regards,
Tomasz Myrta