Subject: [1.7.0] Cannot build statically on Windows

[1.7.0] Cannot build statically on Windows

From: <sisyphus1_at_optusnet.com.au>
Date: Wed, 24 Feb 2016 15:16:20 +1100

Hi,

On Windows, doing a static build of libssh2 (against static openssl and
static libz) used to be a fairly simple task.

On 1.6.0, for example, it was just a matter of making slight amendments to
the configure script:
1) Remove any occurrences of "-DLIBSSH2_WIN32";
2) Append " -lgdi32" to any occurrences of "-lws2_32".

Then run (in msys shell, using gcc compiler):
$ ./configure --disable-shared --enable-static
CPPFLAGS="-IC:/_32/msys_492/1.0/local/include -IC:/_32/msys_492/1.0/local/ssl/include"
LDFLAGS="-LC:/_32/msys_492/1.0/local/lib -LC:/_32/msys_492/1.0/local/ssl/lib"
 --prefix=C:/_32/msys_492/1.0/local && make

Works fine for 1.6.0, but not for 1.7.0.

Everything is fine until we come to building the "example" programs.
With 1.7.0, the first build in "example" aborts with:

gcc -DHAVE_CONFIG_H -I../include -I../example -IC:/_32/msys_492/1.0/local/include
 -IC:/_32/msys_492/1.0/local/ssl/include -MT direct_tcpip.o -MD -MP -MF
.deps/direct_tcpip.Tpo -c -o direct_tcpip.o direct_tcpip.c
mv -f .deps/direct_tcpip.Tpo .deps/direct_tcpip.Po
/bin/sh ../libtool --tag=CC --mode=link
    -LC:/_32/msys_492/1.0/local/lib -LC:/_32/msys_492/1.0/local/ssl/lib -o
direct_tcpip.exe direct_tcpip.o ../src/libssh2.la -lws2_32 -lgdi32
libtool: link: gcc -o direct_tcpip.exe
irect_tcpip.o -LC:/_32/msys_492/1.0/local/lib -LC:/_32/msys_492/1.0/local/ssl/lib
../src/.libs/libssh2.a -lssl -lcrypto -lz -lws2_32 -lgdi32
C:/_32/msys_492/1.0/local/lib/libcrypto.a(e_capi.o):e_capi.c:(.text+0x20f):
undefined reference to `_imp__CertFreeCertificateContext_at_4'
..... and many more undefined references to a number of *dynamic* symbols.

But with 1.6.0 the exact same commands work fine. (And it's the same shell,
same compiler, same environment, same configure command, same everything).
So I'm quite nonplussed as to what accounts for the 1.7.0 failure.

Could it be some difference in the example/Makefile ? (Diff is attached.)
Maybe it's a PEBCAK that I can't spot.

It seems *very* odd that the "src" build is working fine (including the
creation of the static libssh2.a), yet the building of the first "example"
program wants to find *dynamic* symbols.

I think I'll need some help with this.

Cheers,
Rob

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Received on 2016-02-24