Subject: Linking against mingw static library: missing CARES_STATICLIB definition?

Linking against mingw static library: missing CARES_STATICLIB definition?

From: Brad Spencer <spencer_at_starscale.com>
Date: Wed, 14 Apr 2010 18:58:08 -0300

This may or may not apply to Windows in general; I have only tried it
with mingw cross-compiles built on Linux.

I recently upgraded from c-ares-1.6.0. When configuring c-ares-1.7.1
with --disable-shared for mingw, the library builds fine, the
CARES_STATICLIB macro is properly defined in ares_config.h, and the
proper CARES_EXTERN value (nothing) is defined.

However, when you go to link with this static library by including
ares.h (and thus ares_version.h, ares_build.h, and ares_rules.h),
the definition of CARES_STATICLIB is missing. The default behaviour
(shared libraries) kicks in, and you get complaints about missing
__imp_* symbols (since the including files end up thinking they are
going to get a DLL).

To work around this, I hard-wired a definition of CARES_STATICLIB as a
temporary measure. However, clearly this is not the intention, since
there is a quite well-documented configuration framework in c-ares now
(nice work :).

So my question is, is this an oversight? Should CARES_STATICLIB be
defined somewhere other than ares_config.h? Or am I missing something
obvious?

Thanks, as always.

-- 
----------------------------------------------------------
Brad Spencer - spencer_at_starscale.com - www.starscale.com
Received on 2010-04-14