Home > Technology, Tips > Compiling Poppler on Windows

Compiling Poppler on Windows

popplerI’ve been struggling trying to install Poppler under Windows, and there is no much information out there. And the few people who claim that works on Windows don’t say how they did it.

Thus, today I will try to guide you on how to make Poppler works on Windows with QT. The goal of this tutorial is to compile the poppler_qt4viewer demo.

The things you will need

Ok, let’s begin the journey. Before starting you need to download some libraries

You will need QT, at the time I’m writing the latest version is 4.7.4 (source zip, tar.gz). I will recommend you to download the source because it gave me some problems when I downloaded the binaries. Then you need the freetype, cairo, and zlib. However, those are not that easy to find in Windows. So, you can download them from any site that maintains a build like GTK+ or Inkscape. I got mine from the GTK+ site and used the developer version of them. You can use, however, the version of your choice. And finally the other library we need is openjpeg, and you can download the source code and build it from there.

Now that you have the libraries, you will need the tools to build them. So go and set Visual Studio or a compiler for Windows, and you will also need CMake.

Building QT

Before getting into Poppler or other libraries, you will need to build QT. I prefer to build it instead of downloading the binaries, because the compiled version didn’t work for me 😦 . There is a detail instruction set in here. So I will give you the short story.

  1. First unzip the sources into your hard drive, for here on I will call this path $QT_PATH=c:\QT.
  2. Then you need to add the path to the environment variables. Go to My Computer Properties, in the Advanced Tab search for the Environment Variables. Then add to the PATH variable the path to the bin folder of your extracted QT files ($QT_PATH\bin).
  3. Now open a console from Visual Studio, and then go to the $QT_PATH and execute configure and then nmake.
    cd $QT_PATH

    If you have any problem in this part check the installation page.

Preparing the environment

After you get all the libraries (cairo, freetype, zlib, and openjpeg) you need to unzip them into a folder, I will call it $TOOLS from here on.

Then, for example, you will have $TOOLS\cairo-dev_1.10.2-1_win32 if you choose the development version of cairo library. And all the other libraries can be in this folder too. We will use them later when compiling Poppler. In my case I used the dev versions of all the libraries, and in order to make it easier I will refer to them as follows

  • $CAIRO = $TOOLS\cairo-dev_1.10.2-1_win32
  • $FREETYPE = $TOOLS\freetype-dev_2.4.2-1_win32
  • $ZLIB = $TOOLS\zlib-dev_1.2.5-2_win32
  • $OPENJPEG = $TOOLS\openjpeg_v1_4_sources_r697

Building Openjpeg

Now we will build Openjpeg using CMake. Open CMake GUI and in the source path choose $OPENJPEG path; for the build binaries you need to create a folder, mine is $OPENJPEG\build. Then you just need to press Configure; select your version of Visual Studio and wait for it to end, and then just press it again. It should be no more red rows in the output. If there are, try to solve the problems it mention. After that press Generate and the project should be in $OPENJPEG\build or wherever you put it.

Then open ALL_BUILD project and compile it. The binaries will be in $OPENJPEG\build\bin.

Building Poppler Library

Note: Different target names for Debug and Release.
In case you need to give a postfix to the debug and release libraries, e.g., popplerd.lib for debug and poppler.lib for release, you need to add this line to the CMakeList (after the set(CMAKE_MODULE_PATH ... ) is OK)


Just change the d for the postfix you want to use, maybe _d.

Now that we have all the prerequisites we are ready to build Poppler. Put the sources in a folder, I will call it $POPPLER, and create a folder for the build like in the openjpeg step, mine it is in $POPPLER\build.

Now open CMake, and point the source-path to $POPPLER and the build-path to $POPPLER\build, and press Configure. Again, select the Visual Studio of your choice and then wait for it to configure. An error message will appear regarding the freetype library, don’t worry we are expecting it. You will see a lot of red rows in the output. Look for FREETYPE_INCLUDE_DIR_freetype2, FREETYPE_INCLUDE_DIR_ft2build, FREETYPE_LIBRARY and point them to:

  • FREETYPE_INCLUDE_DIR_freetype2: $FREETYPE\include\freetype2
  • FREETYPE_INCLUDE_DIR_ft2build: $FREETYPE\include
  • FREETYPE_LIBRARY:$FREETYPE\lib\freetype.lib

Then hit Configure again and wait. An error will occur again, and we will need to set the cairo and zlib libraries. Look for the next variables and set them accordingly

  • CAIRO_LIBRARY: $CAIRO\lib\cairo.lib
  • LIBOPENJPEG_LIBRARIES: $OPENJPEG\bulid\bin\Release\openjpeg.lib (this can be Release or Debug depends on you)

Also, you need to change the zlib variables. If you don’t see them, mark the Advance option.

  • ZLIB_LIBRARY: $ZLIB\lib\zdll.lib

Take special attention to this variables if you have a LaTex related system in you computer because it will look for that binaries. However, if the include libraries are not there Poppler won’t compile.

After you change those variables, you need to disable the options WITH_Iconv, WITH_PNG, and WITH_GLIB. And then press Configure again, check for no red rows and then press Generate. Go to $POPPLER\build and execute ALL_BUILD, compile and that should be it for the Poppler library.

Executing the Demo

If you want to execute the demo, and you didn’t add everything to your path you will need some libraries in order to run it. The demo will be located at $POPPLER\build\qt4\demos\Debug or Release accordingly to your compiling settings. You will need the following libraries

  • poppler-qt4.dll: $POPPLER\build\qt4\src\Debug
  • openjpeg.dll: $OPENJPEG\build\bin\Debug
  • QtCored4.dll, QtGuid4.dll, QtTestd4.dll, QtXmld4.dll: $QT_PATH\lib (the ‘d’ is needed if you are working with Debug version, if it is Release version loose it)

If you want to port your demo, you will need to add the msvcpX.dll and msvcrX.dll where X is the number of your compiler (also the debug version of those libraries, the ones that includes the ‘d’), you can find those libraries in your system.

Fonts problems?

I encounter some problems with the demo. The application started, it open the PDFs but no fonts appeared. After struggling a little bit I found that I need the freetype6.dll, I found that library in my installation of Inkscape. However, I’m not sure why the Debug version doesn’t ask for the library. Nevertheless, if you put that library in your Release version the fonts start appearing.


Up to here I was able to build the Poppler library and run the demo inside. I will explore further to see the capabilities of the library and how can I incorporate it into my projects. I hope this help you, so you won’t waste your time trying to do things that, now that I know how to do them, look easy but are not when there is not enough documentation around.

It is hard at the beginning but if you struggle long enough it becomes easier.  :mrgreen:

  1. Kaitnieks
    July 17, 2011 at 6:27 pm

    Thank you very much. I followed your instructions and was able to compile the library. I can’t figure out how to use it in qt creator yet, but it’s a start, so thanks.

    • July 17, 2011 at 9:43 pm

      Sure, np…
      I cannot guide you there, ’cause I haven’t tested yet. But good luck on that.
      If you find something please share it… :mrgreen:

  2. Kaitnieks
    July 18, 2011 at 3:41 am

    I’ve been working on this all day and it gets more depressing by every minute. Even though I managed to compile both lpoppler and lpoppler-qt4 (after I realized that I need the visual studio version of QT, not mingw version), these didn’t work in QT Creator and I’m not sure why (undefined reference to `_imp___ZN7Poppler8Document4loadERK7QStringRK10QByteArrayS6_’). I figure it’s because I compiled libraries with Visual Studio but my QT Creator uses mingw. I could not compile poppler with mingw (it compiled lpoppler, but lpoppler-qt4 was excluded from makefile without any error messages or explanation).

    I guess my next step is to remake them again (just to be sure, I’ll use VS 2008 not 2010 this time) and try to use VS2008 compiler in Qt creator.

    Is this the kind of crap c++ programmers deal with all the time?

    • July 18, 2011 at 9:36 am

      Hi Kaitnieks,
      I’m not sure if the compiler version had something to do with your error. But just to be sure, use the same compiler version in all the process.
      In my case, I did everything with VS2010. Even to compile QT, because it gave me some errors when I used the QT binaries.
      Good luck, and keep doing it…

  3. Alex
    July 31, 2011 at 10:49 am

    Hey I want to say thank you for this.
    It worked for me perfectly.

    I too have noticed the font problem. So is there no way to make the fonts appear with the debug version of the library?

    • August 1, 2011 at 3:01 pm

      I’m glad it was useful. :mrgreen:
      And for the font problem, I don’t know. When I added the library stated above (freetype6.dll) it worked. But I don’t know if the problem is related to free type or to poppler. 😦

  4. KD-Phil
    August 10, 2011 at 6:43 am

    Hello, Little feedback.
    First of all, i thank you for this article.
    I was faced with a compilation problem under Windows SP1 seven, with the option ENABLE_ZLIB, and the use of MSYS.
    Activation of the variable in ENABLE_ZLIB CMAKE had no effect on the compilation, producing a multiple definition of the class FlateStream in the file and the file Stream.h FlateStream.h.
    Setting this variable in the file “Stream.h” to report using the zlib library had no effect.
    I had to comment out the code between the directives:
    # ifndef ENABLE_ZLIB
    / *

    * /
    # endif
    in files “Stream.h” and “Stream.cc” for the compilation is done.
    I also activated the ENABLE_SPLASH variable for that compilation takes place. This is needed so the PSOutputDev.h and PSOutputDev.cc compilation.

    Finally, the compilation was successful and the demonstration of Poppler QT4 was performed.

  5. zacknov
    September 24, 2011 at 9:58 pm

    Very pleased to read your blog, because it has found a way to make the program read pdf files. I’ve had 3 days looking for library to open a pdf file, and finally found your blog. I plan on using IDE CodeBlocks with MinGW on windows vista operating system.

  6. xiangxw
    October 7, 2011 at 5:18 pm


  7. Clemens
    November 7, 2011 at 5:30 am

    Great to share this information with us, but I’m yet not familiar with Qt etc. programing – so what about the helpful act just sharing the compiled windows binaries with us? Please!!

    (…wondering at all why there is no place with newest poppler windows binaries!?!…)

    Thanks a lot

  8. craig
    November 15, 2011 at 8:17 am

    holy shit getting poppler to compile on windows is making me crazy.

    Your blog post seems to be the only guide on the whole internet. all I am interested in is the pdftohtml.exe utility.

    Everything compiles in visual studio 2010 and when I execute it, it complains about missing openjpeg.dll and freetype6.dll
    When I put those dlls into the same directory as pdftohtml and launch it, I get this error:

    pdftohtml.exe – Application Error
    The application was unable to start correctly (0xc000007b). Click OK to close the application.

    I have tried using your guide to get it to build with mingw and when I open the mingw shell and execute make the shell crashes.

    Please, please, please can you make a windows binary available for the 0.18.1 release of poppler?

    • November 15, 2011 at 10:52 am

      Hi, craig. Don’t worry, it will work sooner or later. Just don’t give up.

      I don’t have the 0.18.1 release, so I can’t help you with that. I have an older release. However, you should check that the libraries version match. That is, if you are compiling poppler as release, then the openjpeg libraries should also be release libraries. If you fail doing this you can have several errors.

      Check that and let me know if it works or not.

  9. December 2, 2011 at 1:36 am

    thank your for this article!:
    when building “ALL_BUILD” in VS 2008, I got

    fatal error LNK1257: code generation failed
    in three files:
    – j2k_dump
    – image_to_j2k
    – j2k_to_image

    what can be the problem?

    • kalyan
      March 8, 2012 at 6:20 pm

      @Oleh Ziats:how you resolved these errors in VS2008

  10. Chris Peto
    January 5, 2012 at 6:10 pm

    Thanks for this, it works great!

    Do you know anything about compiling for Mac?

  11. January 12, 2012 at 1:43 am

    Ah, I remember fighting that fight sometime in 2010, IIRC. Took forever to get right and then I couldn’t remember how exactly I did it and therefore couldn’t blog about it. I used mingw, but maybe the project needs to be switched to MSVC and I was dreading doing that because of poppler. So, this post is very useful. Thank you! 🙂

    @Chris Peto: The easiest way might be to use Homebrew (http://mxcl.github.com/homebrew/). That’s how I got the above mentioned project to build on Lion. The downside is, that you’ll need to install Qt with homebrew as well. The upside is, though, that macdeployqt finds all the libraries, including poppler. Which was a pain when I built poppler (and other dependencies like QJson) manually on Snow Leopard. Ended up copying the *.dylib files to /usr/lib, which obviously sucks.

    There’s one catch, however; Homebrew installs libraries read-only to /usr/local/lib (actually symlinks them there, they are really in /usr/local/Cellar/libfoo-1.2.3/lib). macdeployqt needs to write to those dylib files when doing it’s thing, so those libraries need to be writable. I wrote a little script that installs the dependencies and sets the permissions. Not the neatest solution either, but better than putting stuff in /usr/lib.

    My setup_mac.sh script for the project using Qt, QJson and poppler looks like this:

    command -v brew || { echo “Homebrew is required. Please install it first: http://mxcl.github.com/homebrew/” >&2; exit 23; }

    echo “Installing Libraries…”
    brew install qjson || { echo “Failed!”; exit 23; }
    brew install poppler –with-qt4 || { echo “Failed!”; exit 23; }
    echo “Done.”

    echo “Settings permissions on libraries to make macdeployqt work…”
    chmod -R -L u+w /usr/local/lib/* || { echo “Failed!”; exit 23; }
    echo “Done.”


  12. kalyan
    March 7, 2012 at 9:06 pm

    @oleh ziats:how you resolved the LNK1257

  13. March 8, 2012 at 11:38 pm

    Very clear tutorial: THANKS A LOT!!!!

  14. Ziku
    May 7, 2012 at 2:34 pm

    I need help building in XCode for IOS/iPad using Poppler. This is for my personal research and educational project to experiment some pdf reading and annotation. I would be grateful if you can help or share some resource from where I can get help.


  15. November 21, 2012 at 11:39 am

    I followed the tutorial but had a strange problem on windows 7, the file is not found. Anybody else get this and solve it?

  16. November 21, 2012 at 11:40 am

    file fontconfig.h is not found

  17. Suhong Yoo
    July 3, 2013 at 4:56 pm

    Thank you for your kind explanation.

    However, I have a problem with QT library compling.

    The problem is CMAKE can not found qtdbus.lib file.

    So, I downloaded 4.3.5, 4.5.3, 4.6.4, 4.7.4, 4.8.4 and 4.8.5 version and complied the source, respectively.

    But I can not found qtdbus.lib file any version, though the source file(.cpp) was exist in “include” folder.

    I want to know the ways to compile the qtdbus library file.

    Please answer to me.

    • September 14, 2013 at 9:16 pm

      d-bus is not supported under windows

  18. Lee
    December 21, 2013 at 6:32 am

    Thank you adin for taking the time to share this – so useful and time saving.

  19. February 22, 2014 at 12:10 am

    Thanks a lot for these instructions, great detail for people like me who’ve never used cmake.

    I followed these to build a QT 5.2 version with Visual Studio Express 2012. Most of what you write still applies.

    Some changes:
    * compilation errors in qdatetime.h… due to the fact that windows.h contains a #define min, and qdatetime defines a min method. Solution is to define #define NOMINMAX before including windows.h. I did that at the to of the 4 files which broke… I guess if you know where windows.h is included you can do this just once
    * fontconfig/fontconfig.h was not found… I disabled cairo which according to wikipedia is not used for QT… example shows a PDF so I guess it’s true.
    * for QT5 it’s important that you add the /Zc:wchar_t option for all builds. I added this to CMAKE_CXX_FLAGS. If you don’t you get link errors on poppler-qt5.dll, e.g. related to QString::toWCharArray.
    * I needed to get a more recent version from zlib, else there are link problems, I used the 1.2.8 dll download from zlib.net
    * I disabled QT4 build and test in cmake tool

    Build now works except for 1 example which includes unistd.h… I ignored…

    After making sure all DLL’s can be accessed the qt5 example runs and can load & save PDF. Not sure if I’ll hit other problems later.

  20. November 14, 2014 at 11:27 pm

    Thanks for the material . But I am getting an error on compiling popper , it says : Error 18 error LNK1104: cannot open file ‘..\Debug\poppler.lib’ can you help me ?

  21. February 26, 2019 at 9:01 am

    It’s 2019, and getting poppler to work on windows is as complicated for me as it was to my forefathers.
    It seems that Cmake can’t find pkg_config (because there’s none) but it also says that it’s optional, so why is it failing?

    CMake Error at D:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
    Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
    Call Stack (most recent call first):
    D:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
    D:/Program Files/CMake/share/cmake-3.13/Modules/FindPkgConfig.cmake:39 (find_package_handle_standard_args)
    cmake/modules/FindGLIB.cmake:16 (find_package)
    cmake/modules/MacroOptionalFindPackage.cmake:32 (find_package)
    CMakeLists.txt:172 (macro_optional_find_package)

  22. January 6, 2021 at 6:31 pm

    You can play on-line on line casino video games with simplicity these days. The clients can perform right here all these video games and get for themselves fantastic sums of real money. I’ve talked about spirits and Angels alot lately.

  1. March 8, 2012 at 11:35 pm
  2. January 8, 2015 at 1:09 pm
  3. February 1, 2019 at 8:08 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: