[cairo] Cairo win32 Static linking

WC Black blackwc88 at gmail.com
Tue Feb 4 00:27:34 PST 2014


Sorry about the last forward. Meant to do this one. The definition 
wasn't present in a project. Thanks for helping me even though it was a 
silly mistake on my part.

On 2/2/2014 6:00 AM, John Emmas wrote:
> On 01/02/2014 17:08, WC Black wrote:
>> I'm having trouble linking to cairo-static.
>>
>> I'm on windows compiling with VC. I compiled cairo myself using msys 
>> and VC.
>>
>> I get many of these:
>> error LNK2019: unresolved external symbol __imp__cairo_create
>> error LNK2019: unresolved external symbol __imp__cairo_destroy
>> etc.
>>
>
> According to 'src/cairo.h' you need to define CAIRO_WIN32_STATIC_BUILD 
> if you've built cairo statically. However, it looks like you'll need 
> to define that for any library which links to cairo (i.e. rather than 
> defining it when building cairo itself). Defining that preprocessor 
> directive will ensure that 'cairo-public' is correctly defined for 
> those libraries which link to cairo - BUT -
>
> What's interesting (admittedly from just a cursory glance) is that in 
> 'src/cairoint.h', when building with MSVC, 'cairo_public' is defined 
> as __declspec(dllexport).  So when you build cairo statically it's 
> probably just a happy accident if the library's symbols end up correct 
> (i.e. the compiler was clever enough to realise that a static library 
> can't have dllexported symbols).
>
> Try defining CAIRO_WIN32_STATIC_BUILD for any libraries where you're 
> seeing those unresolved externals.  You'll need to rebuild those libs 
> but hopefully, the errors will go away.
>
> A silly question but....  why do you need cairo to be a static lib 
> anyway?
>
> John



More information about the cairo mailing list