Subject: A question about windows static library linkage

A question about windows static library linkage

From: Bill Segall <bill_at_segall.net>
Date: Tue, 24 May 2011 20:39:04 +1000

Sorry to be asking so many questions today but I'm also endeavoring to build
libssh2 for Windows.

I want to use static libraries and to support MD, MDd, MT, and MTd variants
on both win32 and x64. (Don't ask!) We're using Visual Studio9.1 and I was
able to convert the VS6 dsw without any issues, cut it down to just the
win32/MD[d] build and with some tweaks get it to build the library for me
without any problems.

When building the sample against the static library I get libssh2 undefined
symbols of the form:
Error 1 error LNK2001: unresolved external symbol
__imp__libssh2_exit simple.obj tests

which is the result of not wanting the declspec(dllimport) definitinition in
libssh2.h to be active. I can resolve this by defining LIBSSH2_API in
sample.c but I wanted to check that was the correct usage of that in an
application. It struck me that this preprocessor symbol had the appearance
of being internal to the library and I thought I should ask whether this is
the defined mechanism for achieving static linkage on Windows.

Thanks again,
Bill.
PS. I'd be happy to provide a VS9.1 solution once it was complete if that
was useful.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-05-24