c++buildcmakemingwpodofo

Building PoDoFo library using CMake and MinGW


I am trying to build PoDoFo Library on my Windows Platform (for use as an API). It is done using CMake. The ReadMe file says the following. Unfortunately I am new to CMake and I can't make out much from it.

Building PoDoFo on Windows

CMake 2.6.x is required for Windows. You can download it from cmake.org .

On Windows, PoDoFo may be built as either a shared or static library. Building both is not supported. By default only the shared library will be built. If you want a static library, just disable generation of the shared library with the extra argument to cmake:

    -DPODOFO_BUILD_SHARED=FALSE

Handling library naming on win32

Especially on Windows it is also common for custom built libraries to have different names to those you might download as pre-built copies. CMake won't be able to find them if they're called something else unless you tell it. Use these variables to tell CMake what names to look for a library under:

•FREETYPE_LIBRARY_NAMES_DEBUG, FREETYPE_LIBRARY_NAMES_RELEASE and FREETYPE_LIBRARY_NAMES
•TIFF_LIBRARY_NAMES_DEBUG, TIFF_LIBRARY_NAMES_RELEASE and TIFF_LIBRARY_NAMES 
•LIBJPEG_LIBRARY_NAMES_DEBUG, LIBJPEG_LIBRARY_NAMES_RELEASE and LIBJPEG_LIBRARY_NAMES
•ZLIB_LIBRARY_NAMES_DEBUG, ZLIB_LIBRARY_NAMES_RELEASE,ZLIB_LIBRARY_NAMES

CMake builds on Windows with MinGW

Once MinGW is set up, make sure that the MinGW "bin" directory is on your PATH, and be sure to set CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH such that CMake can find the headers and .lib files for the libraries PoDoFo requires. The GnuWin32 library packages from http://gnuwin32.sf.net/ are known to work with PoDoFo, so installing zlib, freetype, and libjpeg from there should do the trick.

To configure and build PoDoFo with a default GnuWin32 install and with MinGW already on your PATH:

md ..\podofo-debug 
cd ..\podofo-debug
cmake -G "MinGW Makefiles" ..\podofo-src -DCMAKE_INCLUDE_PATH=c:\progra~1\gnuwin32\include -DCMAKE_LIBRARY_PATH=c:\progra~1\gnuwin32\lib -DPODOFO_BUILD_SHARED:BOOL=FALSE mingw32-make

I have installed CMake and downloaded the other libraries mentioned like freetype, zlib, libjpeg. Their header and binary files are in their respective folders.

Now what should DCMAKE_INCLUDE_PATH and DCMAKE_LIBRARY_PATH be? Also what is "MinGW Makefiles"? Do I have to supply any extra parameters?

I'll be grateful if someone can explain in simple steps how I can go about it.

EDIT: error while executing CMAKE:

-- Ensure you cppunit installed version is at least 1.12.0
Cppunit not found. No unit tests will be built.
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPack
ageHandleStandardArgs.cmake:97 (message):
  Could NOT find FREETYPE (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR)
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStan
dardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindFREETYPE.cmake:75 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:372 (FIND_PACKAGE)

Solution

  • If you followed all the instructions, to compile it should normally be enough to do:

    cd <podofo root directory (where CMakeLists.txt is)>
    mkdir build 
    cd build
    cmake -G "MinGW Makefiles" -DCMAKE_INCLUDE_PATH=<path to headers> -DCMAKE_LIBRARY_PATH=<path to libraries> -DPODOFO_BUILD_SHARED:BOOL=FALSE ..
    mingw32-make
    

    Step by step: First, go to the directory where your podofo sources are. You should see a CMakeLists.txt file lying around.

    Second (and third), create (and go into) a directory where the compilation will be done. I call it build but it can be any name. This is a best practice since you can simply delete the build directory and come back to a clean state.

    Fourth, ask cmake to create the makefile(s) for mingw:

    Last, but not least, compile with the mingw version of make.