Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Building poppler (pdf) with Qt problem (POSIX): (2 Items)
   
Building poppler (pdf) with Qt problem (POSIX)  
I need a pdf support with Qt 4.7.1 in my QNX 6.5.0, installed to VMWare Workstation. I try to build poppler ver.0.20.3 
(poppler.freedesktop.org) in next few steps (GCC 4.4.2.):

0) Configure, build and install all dependencies of poppler (Fontconfig-2.10.1, Cairo-1.12.2, libjpeg-8d and libpng-1.5.
12).

1) Set proper environment variables to build poppler:

#!/bin/sh
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export CFLAGS="-I/usr/local/include/pixman-1 -I/usr/include/qt4 -I/usr/pkg/include"
export LDFLAGS="-L/usr/local/lib -L/x86/usr/lib -L/usr/lib -L/usr/pkg/lib"
export LIBS="-lpixman-1 -lQtGui -lQtCore -lQtNetwork -lopenjpeg"
export CXXFLAGS=${CFLAGS}
export FREETYPE_CFLAGS=-I/usr/local/include/freetype2
export FREETYPE_LIBS="-L/usr/local/lib -lfreetype"
export FONTCONFIG_CFLAGS=-I/usr/local/include/fontconfig
export FONTCONFIG_LIBS="-L/usr/local/lib -lfontconfig"
export CAIRO_CFLAGS=-I/usr/local/include/cairo
export CAIRO_LIBS="-L/usr/local/lib -lcairo"

2) Unpack and configure it (see log file in the attachment):

# ./configure --disable-jpeg

3) When I try to build poppler it fails with error in goo/gfile.cc:

# make
make  all-recursive
make[1]: Entering directory `/home/ftp/poppler-0.20.3'
Making all in goo
make[2]: Entering directory `/home/ftp/poppler-0.20.3/goo'
  CXX    gfile.lo
gfile.cc: In function 'GooString* getHomeDir()':
gfile.cc:99: error: 'getuid' was not declared in this scope
gfile.cc: In function 'GooString* getCurrentDir()':
gfile.cc:121: error: 'getcwd' was not declared in this scope
gfile.cc: In function 'GooString* makePathAbsolute(GooString*)':
gfile.cc:437: error: 'getcwd' was not declared in this scope
gfile.cc: In function 'std::time_t getModTime(char*)':
gfile.cc:455: error: no matching function for call to 'stat::stat(char*&, stat*)'
/usr/qnx650/target/qnx6/usr/include/sys/stat.h:133: note: candidates are: stat::stat()
/usr/qnx650/target/qnx6/usr/include/sys/stat.h:133: note:                 stat::stat(const stat&)
gfile.cc: In function 'GBool openTempFile(GooString**, std::FILE**, const char*)':
gfile.cc:531: error: 'mkstemp' was not declared in this scope
gfile.cc: In constructor 'GDirEntry::GDirEntry(char*, char*, GBool)':
gfile.cc:715: error: no matching function for call to 'stat::stat(char*, stat*)'
/usr/qnx650/target/qnx6/usr/include/sys/stat.h:133: note: candidates are: stat::stat()
/usr/qnx650/target/qnx6/usr/include/sys/stat.h:133: note:                 stat::stat(const stat&)
make[2]: *** [gfile.lo] Error 1
make[2]: Leaving directory `/home/ftp/poppler-0.20.3/goo'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ftp/poppler-0.20.3'
make: *** [all] Error 2

-
Functions getuid(), getcwd() and getcwd() are in my <pwd.h> file, but their declarations are covered 
by macros:

#ifdef __EXT_POSIX1_198808
	/* declarations */
#endif

Error with stat::stat(char*&, stat*) because g++ trying to call struct constructor instead of call function stat(char*&, stat*), that declared in <sys/stat.h>.

Declaration of mkstemp() in <stdlib.h> is macro protected too:

#if defined(__EXT_XOPEN_EX)
	/* declarations */
#endif

I tried to build poppler in Win7 (msys+MinGW) and everything was ok, it's works. Poppler binaries for pkgsrc from ftp.
netbsd.org are without \Splash\ support, but I need this backend.

Define macros manually in $CFLAGS ("... -D__EXT_XOPEN_EX -D__EXT_POSIX1_198808") did not solve my problem.

-
So, my questions:

1) What is the correct way to set POSIX version in headers?
2) Why stat() function can't be called?
3) What I need to do to define __EXT_XOPEN_EX macro?

Thanks.
Attachment: Text config.log 92.68 KB
Re: Building poppler (pdf) with Qt problem (POSIX)  
Ok, here is the answer. You need to add follow macro definitions to $CFLAGS and $CXXFLAGS:

CXXFLAGS="-D_XOPEN_SOURCE=600 -std=gnu++0x"
CFLAGS="-D_XOPEN_SOURCE=600 -std=gnu99"

Explanation from Suzuki Toshiya (poppler@lists.freedesktop.org):

«Just I've checked that current main trunk of poppler can be built with
Blackberry Playbook NDK (QNX 6.5.0), with following flags to use POSIX
environment in QNX:
        CXXFLAGS="-D_XOPEN_SOURCE=600 -std=gnu++0x"
        CFLAGS="-D_XOPEN_SOURCE=600 -std=gnu99"

The background of the flags are following:

-D_XOPEN_SOURCE=600
* to enable getpwnam() etc, just -D_POSIX_SOURCE is sufficient.
* to enable strtok_r(), -D_POSIX_C_SOURCE=199506 or newer is sufficient.
* to enable mkstemp(), -D_XOPEN_SOURCE=600 is needed.

-std=gnu++0x and -std=gnu99
* isfinite() is defined in GNU C, C99, and POSIX 2004.
QNX 6.5.0's header file covers POSIX 1998-2001, but not
2004, so "-std=gnu++0x" (for CXXFLAGS) or "-std=gnu99"
are required.

Regards,
mpsuzuki»