Subject: Re: Compile error in examples under MinGW

Re: Compile error in examples under MinGW

From: Luis Lavena <luislavena_at_gmail.com>
Date: Sat, 11 Dec 2010 22:05:52 -0300

On Sat, Dec 11, 2010 at 6:04 PM, Luis Lavena <luislavena_at_gmail.com> wrote:
>>
>>> 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
>> enough.
>>
>
> Can you provide a link to your work? I would love take a look and see
> what needs to be changed in libssh2
>

I've managed to get all the examples build against the static library
changing LIBSSH2_API definition:

 /* Allow alternate API prefix from CFLAGS or calling app */
 #ifndef LIBSSH2_API
 # ifdef LIBSSH2_WIN32
 # ifdef LIBSSH2_LIBRARY
-# define LIBSSH2_API __declspec(dllexport)
+# define LIBSSH2_API extern
 # else
-# define LIBSSH2_API __declspec(dllimport)
+# define LIBSSH2_API extern
 # endif /* LIBSSH2_LIBRARY */
 # else /* !LIBSSH2_WIN32 */
 # define LIBSSH2_API

Tomorrow will investigate how to differentiate when linking against
the static library or the shared library.

Cheers,

-- 
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-12-12