wxQt: fails to link because function names are decorated with import library exports from Cairo. (Issue #26224)

35 views
Skip to first unread message

Carlo Bramini

unread,
Feb 22, 2026, 10:25:59 AM (3 days ago) Feb 22
to wx-...@googlegroups.com, Subscribed
carlo-bramini created an issue (wxWidgets/wxWidgets#26224)

Build System Used

I build wxWidgets and/or my application using:

  • CMake
  • configure
  • mingw32-make with makefile.gcc
  • MSBuild (Microsoft Visual Studio solution file)
  • nmake with makefile.vc
  • Xcode

Description

Testing the build will print this warning:

/usr/include/cairo/cairo.h:70:9: warning: "cairo_public" redefined
   70 | #define cairo_public _cairo_api extern
      |         ^~~~~~~~~~~~
src/common/cairo.cpp:19:9: note: this is the location of the previous definition
   19 | #define cairo_public
      |         ^~~~~~~~~~~~

and later the final link will fail with many messages like these ones:

[0/12] Linking CXX shared library lib/cygwx_qtu_core-3.2-0.dll
ld: libs/core/CMakeFiles/wxcore.dir/__/__/__/__/src/generic/graphicc.cpp.o: in function `wxCairoPathData::MoveToPoint(double, double)':
src/generic/graphicc.cpp:1293:(.text+0x1b7): undefined reference to `__imp_cairo_move_to'
ld: libs/core/CMakeFiles/wxcore.dir/__/__/__/__/src/generic/graphicc.cpp.o: in function `wxCairoPathData::AddLineToPoint(double, double)':
src/generic/graphicc.cpp:1298:(.text+0x1c7): undefined reference to `__imp_cairo_line_to'
ld: libs/core/CMakeFiles/wxcore.dir/__/__/__/__/src/generic/graphicc.cpp.o: in function `wxCairoPathData::~wxCairoPathData()':
src/generic/graphicc.cpp:1261:(.text+0x1e4): undefined reference to `__imp_cairo_destroy'
...etc

This error happens because the particular behaviour of DLLs.
This is how cairo handles the dllexport/dllimport modifiers:
https://cgit.freedesktop.org/cairo/tree/src/cairo.h#n53

#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(CAIRO_WIN32_STATIC_BUILD)
# define _cairo_export __declspec(dllexport)
# define _cairo_import __declspec(dllimport)
#elif defined(__GNUC__)
# define _cairo_export __attribute__((__visibility__("default")))
# define _cairo_import
#else
# define _cairo_export
# define _cairo_import
#endif

#ifdef CAIRO_COMPILATION
# define _cairo_api _cairo_export
#else
# define _cairo_api _cairo_import
#endif

#define cairo_public _cairo_api extern

So, declaring cairo_public doesn't avoid the use of dllexport/dllimport.
At the time of writing, I confirm that hacking the use of CAIRO_WIN32_STATIC_BUILD is the only way to build it.

However, it may be working in the past because a different behaviour of cairo_public into older versions of Cairo, so it must be inspected from which version this has changed and if such older versions are still able to be used by the current code.

Platform and version information

  • wxWidgets version you are building: 3.2.9
  • wxWidgets port you are building: wxQt
  • OS and its version: CYGWIN/WIN32
  • Compiler being used: gcc-13.4.0
  • Non-default compiler options, if any : None.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224@github.com>

VZ

unread,
Feb 22, 2026, 10:49:20 AM (3 days ago) Feb 22
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26224)

The linked PR should fix this, but I didn't test it.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3941248450@github.com>

Carlo Bramini

unread,
Feb 22, 2026, 6:40:48 PM (3 days ago) Feb 22
to wx-...@googlegroups.com, Subscribed
carlo-bramini left a comment (wxWidgets/wxWidgets#26224)

I have seen your patch, perhaps I'm missing some information, but what about doing just this into src/common/cairo.cpp:

#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 18, 0)
#define CAIRO_WIN32_STATIC_BUILD
#else
#define cairo_public
#endif

without any other change to all other files?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3941925715@github.com>

VZ

unread,
Feb 22, 2026, 6:57:21 PM (3 days ago) Feb 22
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26224)

I didn't realize we could get the version without including the full cairo.h. If we can do this, we should, of course.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3941946476@github.com>

Carlo Bramini

unread,
Feb 22, 2026, 7:11:46 PM (3 days ago) Feb 22
to wx-...@googlegroups.com, Subscribed
carlo-bramini left a comment (wxWidgets/wxWidgets#26224)

BTW, besides src/common/cairo.cpp, this piece of code also exists into src/generic/graphicc.cpp.
I don't know if it would be worth to put it into a common file to be included for both.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3941969125@github.com>

Carlo Bramini

unread,
Feb 23, 2026, 4:48:34 AM (3 days ago) Feb 23
to wx-...@googlegroups.com, Subscribed
carlo-bramini left a comment (wxWidgets/wxWidgets#26224)

I didn't realize we could get the version without including the full cairo.h. If we can do this, we should, of course.

After some searchs, cairo-version.h had been implemented in development version cairo-1.7.5:
https://cgit.freedesktop.org/cairo/commit/cairo-version.h?h=1.8&id=894940b81f0272a2993d3a785fd505b3a4375e6e
and it has been made available since cairo-1.8.0 released in 2008-09-25.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3943696985@github.com>

VZ

unread,
Feb 23, 2026, 5:46:12 AM (3 days ago) Feb 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26224)

OK, here is the new, much simpler, version.

Concerning cairo_public definition in src/generic/graphicc.cpp, I think it's a mistake because the code there is not using dynamic loading at all, so it should probably be just removed.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3943994558@github.com>

Carlo Bramini

unread,
Feb 23, 2026, 11:15:56 AM (2 days ago) Feb 23
to wx-...@googlegroups.com, Subscribed
carlo-bramini left a comment (wxWidgets/wxWidgets#26224)

OK, here is the new, much simpler, version.

Thank you very much!

Concerning cairo_public definition in src/generic/graphicc.cpp, I think it's a mistake because the code there is not using dynamic loading at all, so it should probably be just removed.

src/generic/graphicc.cpp compiles fine, but unfortunately it fails to link again with this message:

[6/20] Linking CXX shared library lib/cygwx_qtu_core-3.2-0.dll
FAILED: [code=1] lib/cygwx_qtu_core-3.2-0.dll lib/libwx_qtu_core-3.2.dll.a

and lot of messages like these ones:

ld: src/generic/graphicc.cpp:1418:(.text+0x1001): undefined reference to `__imp_cairo_save'
ld: src/generic/graphicc.cpp:1419:(.text+0x1019): undefined reference to `__imp_cairo_translate'
ld: src/generic/graphicc.cpp:1420:(.text+0x102c): undefined reference to `__imp_cairo_scale'
ld: src/generic/graphicc.cpp:1421:(.text+0x105b): undefined reference to `__imp_cairo_arc'
ld: src/generic/graphicc.cpp:1422:(.text+0x1065): undefined reference to `__imp_cairo_restore'
ld: src/generic/graphicc.cpp:1423:(.text+0x108b): undefined reference to `__imp_cairo_close_path'
ld: libs/core/CMakeFiles/wxcore.dir/__/__/__/__/src/generic/graphicc.cpp.o: in function `wxCairoPathData::AddArc(double, double, double, double, double, bool)':
src/generic/graphicc.cpp:1336:(.text+0x10e8): undefined reference to `__imp_cairo_arc'
...etc

So, at first sight it seems that a fix is needed there too.

BTW, libcairo.dll.a is not added to the command line when executing the linker on libwx_qtu_core-3.2.dll.a and this is correct.
Infact, in my experiments, I also tried to add libcairo.dll.a by hand, but it didn't work because an error of duplicated symbols, by writing that cairo_arc and __imp_cairo_arc are a duplication, for example.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3945760418@github.com>

VZ

unread,
Feb 23, 2026, 11:48:08 AM (2 days ago) Feb 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26224)

OK, I take my words back, I misunderstood how this was supposed to work: the code in src/generic/graphicc.cpp does use dynamic linking, just indirectly in that it uses the symbols loaded by src/common/cairo.cpp.

I've updated #26229 to reproduce the hack in the other file too.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3945950562@github.com>

Carlo Bramini

unread,
Feb 24, 2026, 7:42:47 AM (yesterday) Feb 24
to wx-...@googlegroups.com, Subscribed
carlo-bramini left a comment (wxWidgets/wxWidgets#26224)

I tested your patch #26229 in my sources and it worked fine.
Great job!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26224/3951510075@github.com>

VZ

unread,
Feb 24, 2026, 10:53:44 AM (yesterday) Feb 24
to wx-...@googlegroups.com, Subscribed

Closed #26224 as completed via 3193ce3.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26224/issue_event/23039751368@github.com>

Reply all
Reply to author
Forward
0 new messages