I build wxWidgets and/or my application using:
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.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
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.![]()
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.![]()
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.![]()
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.![]()
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.![]()
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.![]()
OK, here is the new, much simpler, version.
Thank you very much!
Concerning
cairo_publicdefinition insrc/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.![]()
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.![]()
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.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()