[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: compiling idesk with g++ 3.2



On Sat, Jan 25, 2003 at 02:37:02AM +0100, Thorsten Sauter wrote:

> After upgrading to g++ 3.2 idesk doesn't build anymore from source. I
> got some parser errors in file X11/Xft/Xft.h while trying to compile
> everything with 3.2. Changing the link to 2.95 back helps.

> The following lines contain the error messages from compile:

> g++ -Wall -g -O2 -c Desk.cc -o Desk.o
> In file included from Desk.h:9,
>                  from Desk.cc:1:
> /usr/include/X11/Xft/Xft.h:52: syntax error before `;' token
> /usr/include/X11/Xft/Xft.h:86: 'FT_UInt' is used as a type, but is not defined 
> 	as a type.
> /usr/include/X11/Xft/Xft.h:93: 'FT_UInt' is used as a type, but is not defined 
> 	as a type.
> /usr/include/X11/Xft/Xft.h:190: parse error before `*' token
> [...]

> I have also tried to create a simple hello world examples which only
> include the header file above, but the same errors appears. So I think
> it isn't a problem which only applies to idesk.

Including a single header file doesn't always work. In fact, sometimes it's
supposed not to work. Manpages will often list several include files, in a
specific order. Unfortunately, the Xft manpage does not list any include
files (sigh). But I don't believe that's the problem either. The problem you
see is that Xft uses, but does not define, a FT_UInt typedef (among many
others.) The FreeType library does define it, and the Xft headerfile does
include freetype.h.

But here's what happens when I try:

debian:~/tmp/idesk-0.3.5 > g++ -Wall -g -O2 -c Desk.cc -o Desk.o
In file included from Desk.h:9,
                 from Desk.cc:1:
/usr/include/X11/Xft/Xft.h:35:31: freetype/freetype.h: No such file or directory
[..]

Aha, a Clue(tm). g++-3.2 can't fine freetype.h. But, on my system, neither
can g++-2.95! The difference between g++-3.2 and g++-2.95 seems to be, on my
system at least, that 2.95 stops after failing to include a file, whereas
3.2 just continues on (and fails horribly.) The problem is that
freetype/freetype.h is located in /usr/include/freetype2, which isn't in the
default include path. I'm guessing that you have a different
freetype/freetype.h which IS in your include path but checks for the gcc
version (yeah, I know, I'm reaching), or you altered your g++-2.95
includepaths.

You can test it by creating a little testfile and passing it through cpp
(using the -E flag):

debian:~/tmp/idesk-0.3.5 > cat test.h
#include <X11/Xft/Xft.h>
extern FT_UInt spam;

debian:~/tmp/idesk-0.3.5 > g++ -E -Wall -g -O2 -c Desk.cc  | fgrep FT_UInt
In file included from Desk.h:9,
                 from Desk.cc:1:
/usr/include/X11/Xft/Xft.h:35:31: freetype/freetype.h: No such file or
directory
    FT_UInt glyph;
    FT_UInt glyph;
               const FT_UInt *glyphs,
                 const FT_UInt *glyphs,
                   const FT_UInt *glyphs,
                     const FT_UInt *glyphs,
                   FT_UInt glyph,
                   FT_UInt *missing,
FT_UInt
                const FT_UInt *glyphs,

As you can see, the warning about not being able to include a file, and then
only references to FT_UInt, but no actual definition. The same thing happens
with g++-2.95 on my system; on your system, you might be able to figure out
which freetype.h is being picked up (grep for 'freetype.h' and you'll see
the full pathname like this:
# 1 "/usr/include/freetype2/freetype/freetype.h" 1 3 )

The correct way to compile using Xft seems to be by using
`xft-config --cflags` in the build cflags:

debian:~/tmp/idesk-0.3.5 > xft-config --cflags
-I/usr/include -I/usr/include/freetype2 -I/usr/include

Using that, I can compile fine using either version of gcc. Here's the
g++ -E example:

debian:~/tmp/idesk-0.3.5 > g++ -E -Wall -g -O2 `xft-config --cflags` -c Desk.cc  | fgrep FT_UInt
  typedef unsigned short  FT_UInt16;
  typedef unsigned int    FT_UInt32;
  typedef unsigned int  FT_UInt;
[... many uses of FT_UInt ...]

So, it's a bug in the idesk build system itself :)

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!



Reply to: