Bug #3069
closedWt compile error: cannot convert ‘PangoFontMap*’ to ‘PangoFT2FontMap*’ for argument ‘1’ to ‘PangoContext* pango_ft2_font_map_create_context
0%
Description
Ran into this error well into a build of Wt libraries:
Building CXX object src/CMakeFiles/wt.dir/Wt/FontSupportPango.o
/home/keith/boost1.55.0_inst/wt-3.3.2/src/Wt/FontSupportPango.C: In constructor 'Wt::FontSupport::FontSupport(Wt::WPaintDevice*)':
/home/keith/boost1.55.0_inst/wt-3.3.2/src/Wt/FontSupportPango.C:105: error: cannot convert 'PangoFontMap*' to 'PangoFT2FontMap*' for argument '1' to 'PangoContext* pango_ft2_font_map_create_context(PangoFT2FontMap*)'
make[2]: * [src/CMakeFiles/wt.dir/Wt/FontSupportPango.o] Error 1
make[1]: * [src/CMakeFiles/wt.dir/all] Error 2
make: * [all] Error 2
I'm building static libs to use on an embedded system. I started the build like this:
cmake \
-D MULTI_THREADED=ON \
-D RUNDIR=/var/www/wt \
-D WEBUSER=tkweb \
-D WEBGROUP=tkweb \
-D BOOST_ROOT=/home/keith/boost1.55.0_inst/boost_1_55_0/stage \
-D BOOST_LIBRARYDIR=/home/keith/boost1.55.0_inst/boost_1_55_0/stage/lib \
-D BOOST_INCLUDEDIR=/home/keith/boost1.55.0_inst/boost_1_55_0/boost \
-D SHARED_LIBS=OFF \
-D CONNECTOR_FCGI=OFF \
-D CONNECTOR_HTTP=ON \
-D USERLIB_PREFIX=lib \
-D Boost_USE_STATIC_LIBS=ON \
-D Boost_USE_STATIC_RUNTIME=ON \
-D CONFIGDIR=/etc/wt \
-D CMAKE_INSTALL_PREFIX=/home/keith/boost1.55.0_inst/boost_1_55_0/stage \
../
make
Files
Updated by Keith Stevens over 10 years ago
I got it to compile by casting the argument as:
pango_ft2_font_map_create_context((PangoFT2FontMap*)pangoFontMap);
i.e. changed this:
#if PANGO_VERSION_MAJOR > 1 || PANGO_VERSION_MINOR > 21
context_ = pango_font_map_create_context(pangoFontMap);
#else
context_ = pango_ft2_font_map_create_context(pangoFontMap);
#endif
to this:
#if PANGO_VERSION_MAJOR > 1 || PANGO_VERSION_MINOR > 21
context_ = pango_font_map_create_context(pangoFontMap);
#else
context_ = pango_ft2_font_map_create_context((PangoFT2FontMap*)pangoFontMap);
#endif
Don't know yet if that's going to run without segfault but I'll let you know.
Updated by Keith Stevens over 10 years ago
I resolved this by using an older version.
Updated by Koen Deforche over 10 years ago
- Status changed from New to InProgress
- Assignee set to Koen Deforche
Updated by Koen Deforche over 10 years ago
- Status changed from InProgress to Feedback
Hey,
What version of pango were you using when you had this problem. And what pango version are you using that resolved the problem?
It seems that you should have got this problem only if something was wrong with pango version detection or if you were using a very old pango version?
Regards,
koen
Updated by Alan Finley over 10 years ago
I have the same problem.
I'm trying to build Wt in Centos 5 and pango-1.20.4-1.6
is the newest package I could find for that OS.
So I get a compile error here:
if (!pangoFontMap)
pangoFontMap = pango_ft2_font_map_new();
#if PANGO_VERSION_MAJOR > 1 || PANGO_VERSION_MINOR > 21
context_ = pango_font_map_create_context(pangoFontMap);
#else
context_ = pango_ft2_font_map_create_context(pangoFontMap);
#endif
pango_ft2_font_map_create_context
function takes an argument of type PangoFT2FontMap
, but the pangoFontMap
variable is PangoFontMap
.
Updated by Koen Deforche over 10 years ago
Hey,
Ah, indeed, it looks like casting to PangoFT2FontMap* should be correct. Can you confirm?
Regards,
koen
Updated by Alan Finley over 10 years ago
- File pango.patch pango.patch added
I don't think that using c-style casts on structs is a good idea :)
So I used PANGO_FT2_FONT_MAP
macro to perform cast:
context_ = pango_ft2_font_map_create_context(PANGO_FT2_FONT_MAP(pangoFontMap));
Then I built a simple example with a WRasterImage
:
Wt::WRasterImage pngImage("png", 600, 400);
Wt::WPainter p(&pngImage);
p.drawText(Wt::WRectF(0, 0, 100, 100), Wt::AlignLeft, Wt::TextSingleLine, "PANGO TEST");
std::ofstream f("pango_test.png", std::ios::out | std::ios::binary);
pngImage.write(f);
It produces a png file with a text. The only difference is that I get an image with a white background on Centos 5 and an image with a transparent background on Centos 6. But I'm not sure this is relevant to this issue.
You can see my patch in the attachment.
Updated by Alan Finley over 10 years ago
Also I'm not sure about this ckeck:
#if PANGO_VERSION_MAJOR > 1 || PANGO_VERSION_MINOR > 21
Should it be &&
instead of ||
?
Updated by Koen Deforche over 10 years ago
Hey Alan,
Thanks for the patch.
The check is fine since we want everything later than 1.21 ?
Regards,
koen
Updated by Alan Finley over 10 years ago
Koen Deforche wrote:
The check is fine since we want everything later than 1.21 ?
Old version 0.28 will pass the current check.
I think it should be:
#if PANGO_VERSION_MAJOR >= 1 && PANGO_VERSION_MINOR > 21
Updated by Koen Deforche over 10 years ago
- Status changed from Feedback to Resolved
- Target version set to 3.3.4
Updated by Koen Deforche over 10 years ago
Hey,
Pango 1.0 dates from 2002, and we do not support pango < 1 (which probably has many API differences).
Moreover, the '&&' variant will not match pango 2.0
Regards,
koen
Updated by Koen Deforche about 10 years ago
- Status changed from Resolved to Closed