Re: Compiling libcurl staticly within DLL-module with mingw32

2011-08-21 Thread Alexander Tumin
I have tried to redefine CURL_EXTERN myself, in curl/curl.h after
where it was defined, both to __declspec(dllimport) and
__declspec(dllexport) with no luck - libcurl replaces all dll symbols
by it's own when linked staticly.
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html



Re: Compiling libcurl staticly within DLL-module with mingw32

2011-08-21 Thread Alexander Tumin
After compiling libcurl with -DCURL_STATICLIB
(CPPFLAGS=-DCURL_STATICLIB ./configure
--prefix=/home/crosscompile/i686-mingw32/tree/ ... etc)
all worked! Big thanks to B4gder from #c...@freenode.irc for this hint!
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Compiling libcurl staticly within DLL-module with mingw32

2011-08-20 Thread Alexander Tumin
Hello, i am having troubles compiling libcurl staticly into dll-module
(aka plugin) with mingw32.

Here is the simple testcase illustrating the problem:
http://touhou.ru/upload/7f5f968d62f9a4f83e60f48d76bb694b.zip

 As you can see in Makefile; module.c is compiled twice:
 * once linked staticly with libstatic_curl.a and
 * once linked dynamicly with libcurl-4.dll

 There is no problems with dynamic build - it just works perfectly as expected.

 The problem is that when it is linked staticly: all module's symbols
becomes completely inaccessible with
 GetProcAddress() function from windows.h - it just returns NULL for anything.

 What the possible reason of such behaviour? How it can be fixed?

 Thanks.

 P.S. There is no problems with linking libcurl staticly with native
 linux GCC, in .so format, both dynamic and static linking works:
http://touhou.ru/upload/bebf73514ee48b0526b7ff6de1719b8e.zip
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Compiling libcurl staticly within DLL-module with mingw32

2011-08-20 Thread Gisle Vanem

Alexander Tumin itakingite...@gmail.com wrote:


As you can see in Makefile; module.c is compiled twice:
* once linked staticly with libstatic_curl.a and
* once linked dynamicly with libcurl-4.dll

There is no problems with dynamic build - it just works perfectly as expected.

The problem is that when it is linked staticly: all module's symbols
becomes completely inaccessible with
GetProcAddress() function from windows.h - it just returns NULL for anything.


A static DLL is a self-contradiction. At least when you build it like this:

module_static.dll: module.c
$(CC) -L . -shared module.c -o module_static.dll -DCURL_STATICLIB 
libstatic_curl.a -lws2_32

module_static.dll will have nothing to export because of 'CURL_STATICLIB'. I.e.
'CURL_EXTERN' in curl/curl.h is not '__declspec(dllimport)' as is required 
when
using libcurl dynamically.

Verify this with 'pedump module_static.dll' and 'depends'.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Compiling libcurl staticly within DLL-module with mingw32

2011-08-20 Thread Alexander Tumin
On 20 August 2011 16:26, Gisle Vanem gva...@broadpark.no wrote:
 I.e.
 'CURL_EXTERN' in curl/curl.h is not '__declspec(dllimport)' as is required
 when
 using libcurl dynamically.

 Verify this with 'pedump module_static.dll' and 'depends'.

Here is pedump of module_static.dll:
http://paste.pocoo.org/show/461288/

Seems like libcurl completly replaces all symbols in dll with it's own
ones, as opposed to module_dynamic.dll:
http://paste.pocoo.org/show/461289/

How this can be fixed?
Sorry if i am missing something.
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html