The E-Sheet project needed to be able to create and view PDF's. After looking around, I noticed a lot of people proposed to use Poppler, but to use it I needed to build the libraries. Since there isn't much information out there, I could only base my tries on this tutorial.
Downloads
- Poppler (I used poppler-0.18.4)
- Qt4 or the sources if you want to compile Qt as well. I tried them both and both were successful, so it's up to you.
- MinGW download the installer (e.g. mingw-get-inst-20111118.exe)
- CMake
- Freetype
- Cairo
While building I encountered the following error:
C:/.../CairoOutputDev.h:38:22: fatal error: cairo-ft.h: No such file or directory
To solve this I moved the files located in the/include/cairo
folder to the/include folder
.
Then another error occurred:
C:/.../include/cairo-ft.h:50:35: fatal error: fontconfig/fontconfig.h: No such file or directory
To solve this you will need to download Fontconfig. Once the download is complete copy the/include/fontconfig
folder from the fontconfig archive into the cairo/include
folder. The other parts of the fontconfig archive are not needed. - Openjpeg
- Zlib
Setting up your environment
- Install MinGW and CMake. Add them both to your system path. E.g.
C:\MinGW\bin
andC:\Program Files (x86)\CMake 2.8\bin
- Install Qt or build it. Add it to your system path. E.g.
C:\QtSDK\QtSources\4.8.0\bin
- Extract the archives (Freetype, Cairo, Openjpeg and Zlib) to a folder. I will refer to this folder as
$Tools
. By doing this will we will be able to do the following.$FREETYPE = $TOOLS\freetype-dev_2.4.2-1_win32
$CAIRO = $TOOLS\cairo-dev_1.10.2-1_win32
$OPENJPEG = $TOOLS\openjpeg_v1_4_sources_r697
$ZLIB = $TOOLS\zlib-dev_1.2.5-2_win32
Building Openjpeg
- Open CMake. Enter the path of the source code and the build folder so as the source enter the path represented by
$OPENJPEG
and for the path of the build folder I used$OPENJPEG/build
- Click the "Configure" button.
- Select "MinGW Makefiles"
- Click "Finish" and wait until it is done.
- Once it's done configuring click the "Generate" button and wait until it is done.
- Open command prompt and execute the following commands. Make sure to replace
$OPENJPEG
with the actual path
-
cd $OPENJPEG\build
-
mingw32-make
-
Building Poppler
- Extract the files of the poppler archive. This path will be referred to as
$POPPLER
- Open CMake. Enter the path of the source code and the build folder so as the source enter the path represented by
$POPPLER
and for the path of the build folder I used$POPPLER
/build
- Click the "Configure" button.
- It will tell you an error occurred. Because the path of some variables couldn't be found so enter them manually:
- FREETYPE_INCLUDE_DIR_freetype2:
$FREETYPE\include\freetype2
- FREETYPE_INCLUDE_DIR_ft2build:
$FREETYPE\include
- FREETYPE_LIBRARY:
$FREETYPE\lib\freetype.lib
- CAIRO_INCLUDE_DIR:
$CAIRO\include
- CAIRO_LIBRARY:
$CAIRO\lib\cairo.lib
- LIBOPENJPEG_INCLUDE_DIR:
$OPENJPEG\libopenjpeg
- LIBOPENJPEG_LIBRARIES:
$OPENJPEG\bulid\bin\Debug\openjpeg.lib
- ZLIB_INCLUDE_DIR:
$ZLIB\include
- ZLIB_LIBRARY:
$ZLIB\lib\zdll.lib
- You also need to disable the following variables:
- WITH_Iconv
- WITH_PNG
- WITH_GLIB
If the variable isn't one of the above check which variable couldn't be found and enter the correct path. This might be needed for Qt libraries or MinGW.
It's possible you should view it in Advance mode to see the ZLIB_INCLUDE_DIR and the ZLIB_LIBRARY variables. - FREETYPE_INCLUDE_DIR_freetype2:
- Repeat step 4 until you can configure it without getting an error.
- Once it's done configuring click the "Generate" button and wait until it is done.
- Open command prompt and execute the following commands. Make sure to replace
$POPPLER
with the actual path
-
cd $POPPLER\build
-
mingw32-make
-
Now you can copy all the needed files from the build folder ($POPPLER\build
) or if you're too lazy to do this or if you don't know which files to copy. Make the following adjustments:
- In step 4: set CMAKE_INSTALL_PREFIX to the path where you want all the file to be placed.
Make sure the program has write access on the location you enter! - In step 7: change
mingw32-make
tomingw32-make install
Using Poppler
Create a new project and add the following to the project file:
-
INCLUDEPATH += $POPPLER/include/poppler/qt4
-
LIBS += -L$POPPLER/lib -lpoppler-qt4
Again don't forget to change $POPPLER
to the actual path. Then in the files you need poppler add the following header: #include <poppler-qt4.h>
Comments
Can't build openjpeg...
I followed your instructions but openjpeg wouldn't build. I switched to version 1.5.0 and that worked fine once I'd told it to build its own copies of the thirdparty libraries.
I've now successfully built poppler and can build my own C++/Qt/poppler applications---thanks!
When building poppler, in
When building poppler, in cmake i can not link :
LIBOPENJPEG_LIBRARIES: $OPENJPEG\bulid\bin\Debug\openjpeg.lib
there is no folder debug :s ?
I don't really understand why! can somebody help?
Did you build OPENJPEG before
Did you build OPENJPEG before you continued with Poppler? (
mingw32-make
) If that was successfull you should have the folder. Make sure you're using the correct path. You might have used the default path$OPENJPEG\build\Debug\openjpeg.lib
instead of$OPENJPEG\bulid\bin\Debug\openjpeg.lib
while building it. Check with windows explorer if the files are there.I hope this helps! :)
Hello, Thank you for the
Hello, Thank you for the answer ! Yes i built it! with mingw32-make ! it went until 100% so i think it 's well build! I have only 5 files in the build/bin folder and no debug folder! the 5 files are image_to_j2k.exe, j2k_dump.exe, j2k_to_image.exe, libopenjpg.dll, libopenjpeg.dll.a.
I have link the dll and it
I have link the dll and it worked! i had to dl fontconfig et mov cairo files.
Thank you very much!!!
How did you do this? I'm a
How did you do this? I'm a newbie but I need to use poppler and I have the same problem (no debug folder). In the step 4 I set the libopenjpeg.dll in the openjpeg library. When the step 7 ends I only got a libpoppler.dll in the $POPPLER\build forder, if I set the QT project to find it the only library that I can acsses is poppler-config.h. Where is poppler-qt4.h?
I have correctly include
I have correctly include <poppler-qt4.h>, but when I execute my application, it suddenly close with an exit code.
The erreur is with this line :
Poppler::Document* document = Poppler::Document::load(filename);
Can it be a building problem of poppler who make this error?!
It might be maybe it needs
It might be maybe it needs the debug dll of jpeg... Maybe running it in release mode helps. :)
Also check that the includes in the project file are correct. Note the -L before the $POPPLER, make sure you didn't accidentally removed it. (happened to me :p)
I hope this helps, it has been a long time since I used poppler...
It was the some DLL who
It was the some DLL who missed!
Thank you for this!
Problem
Thank you very much for this perfect tutorials.I have a problem in defining poppler lib to qt.after building poppler in poppler qt4 folder i've got only a .dll file and there is no .lib file.because of that my program can't be built.Please answer my question about .dll and .lib
thanks
If you did everything
If you did everything correctly you should have all the files. Make sure you include all the files correctly into your Qt-project. As stated in the tutorial make sure your replace the
$POPPLER
with the correct path.If that is done correctly is should work, if it doesn't I don't know what you are doing wrong and/or the problem is.
Hi there,
Hi there,
Is this procedure suppose to work on Windows7?
Yes
Yes
Poppler Problem
hello evry body, in my directory build i dont have the poppler-qt4 dll i dont now what is the problem someone can help me please ????
libcairo-2.dll?
i am being asked for a libcairo-2.dll. If i download this(and libfondconfig.dll and zlib1.dll)from the internet the demo works. I have changed the CAIRO_INCLUDE_DIR from include/ to include/cairo because cairo.h is in cairo/cairo.h
Why am i being asked for the libcairo-2.dll... ?
poppler as portable exe under Windows
Hello, is it possible to take the compiled poppler under MinGW and create out of it a portable version that can be used on any PC even without installed MinGW?
That would be great!
Prebuilt Binaries
You can download the Prebuilt Binaries of Poppler 0.24.5 from: https://sourceforge.net/projects/poppler-win32/
Its always updated to the latest STABLE version.
Prebuilt Binaries for Windows
You can download the latest stable version of the prebuilt binaries of Poppler from here: https://sourceforge.net/projects/poppler-win32/
It works with MinGW and Qt5