Subject: Re: Compile error in examples under MinGW

Re: Compile error in examples under MinGW

From: Peter Stuge <>
Date: Sat, 11 Dec 2010 21:52:40 +0100

Luis Lavena wrote:
> also Peter Stuge patch works (removing all the windows stuff from
> direct_tcpip.c), If oyu can commit that change will be great.

I'll have a look.

> There is another problem also:
> /bin/sh ../libtool --tag=CC --mode=link gcc -DLIBSSH2_WIN32
> -DWINSOCK_VERSION=0x0200 -o direct_tcpip.exe direct_tcpip.o
> ../src/ -lws2_32
> libtool: link: gcc -DLIBSSH2_WIN32 -DWINSOCK_VERSION=0x0200 -o
> .libs/direct_tcpip.exe direct_tcpip.o ../src/.libs/libssh2.a -lssl
> -lcrypto -lz -lws2_32
> direct_tcpip.o:direct_tcpip.c:(.text+0xf4): undefined reference to
> `_imp__libssh2_init'

> I've tried both --enable-shared and --disable-static, but the same issue.

Do you want to use a DLL? I have always linked libssh2 statically in
my projects, which may explain why I haven't seen the problem.

> Above is a common problem of usage of __declspec(dllexport) versus
> __declspec(dllimport).

Or linking with the wrong type of library. I've done a fair bit of
research on DLLs in Windows for libusb, in order to build
interchangeable (MinGW and MS) DLLs and static libraries. I believe
I've figured out the minimum that is neccessary, and declspec is not

> Instead, libtool defined DLL_EXPORT:
> Could this be the linking issue?

Sure, but it could also be something else. Can you look into it?

Especially when switching back and forth between options that are
relevant for libtool it's nice to do make distclean, to ensure that
there are no left-overs from a previous build that are causing

Received on 2010-12-11