1

Please scroll to the bottom to list the updated short question

I am building PoDoFo. In the final step, I am using cmake to create the Visual Studio 2010 .sln file for PoDoFo. However when I build this solution file, it can't find header files of dependent libraries. For example, it doesn't find boost library header files.

c:\pdf\podofo-0.9.1\src\base\PdfDefines.h(66): fatal error C1083: Cannot open include file: 'boost/config.hpp': No such file or directory

If I disable boost, I get similar error for freetype library headers

2>..\..\src\doc\PdfFontCache.cpp(55): fatal error C1083: Cannot open include file: 'ft2build.h': No such file or directory

Here is my build.cmd file

del cmakecache.txt

set BOOST_ROOT=C:\pdf\boost_1_51_0_code
set BOOST_INCLUDE_DIR=C:\pdf\boost\boost_1_51_0\staging\include
set BOOSTLIBDIR=C:\workspace\lib\boost\boost_1_51_0\staging\lib

set FT_INCLUDE=C:\PDF\freetype-2.4.0\include\freetype


set FTDIR=C:\PDF\freetype-2.4.0\objs\win32\vc2008
set JPEGDIR=C:\PDF\jpeg-8d\Release\lib
set TIFDIR=C:\PDF\tiff-4.0.3\lib
set ZLIBDIR=C:\pdf\zlib-1.2.8


set BUILD_FLAGS="/MT"

cmake  -G "Visual Studio 10" "C:\pdf\podofo-0.9.1" ^
    -DCMAKE_CXX_FLAGS_RELEASE:STRING=%BUILD_FLAGS%  ^
    -DFREETYPE_INCLUDE_DIR=%FT_INCLUDE% ^
    -DLIBJPEG_LIBRARY_RELEASE=jpeg ^
    -DCMAKE_INCLUDE_PATH="%INCLUDE%;%BOOST_INCLUDE_DIR%;%FT_INCLUDE%;%FT_INCLUDE%\freetype;%JPEGDIR%\jpeg;%TIFDIR%\tiff;%ZLIBDIR%\zlib" ^
    -DCMAKE_LIBRARY_PATH="%LIB%;%BOOSTLIBDIR%;%FTDIR%;%JPEGDIR%\lib;%TIFDIR%;%ZLIBDIR%\lib" ^
    -DPODOFO_BUILD_SHARED:BOOL=FALSE ^
    -DPODOFO_BUILD_STATIC:BOOL=TRUE ^
    -DWANT_BOOST:BOOL=0 ^
    -DLIBJPEG_LIBRARY_NAMES_RELEASE=jpeg ^
    -DFREETYPE_LIBRARY_NAMES_RELEASE=freetype240MT ^
    -DZLIB_LIBRARY_NAMES_RELEASE=zlibstat

I am new to CMake and I don't understand how the library dependencies carry through to the Visual Studio projects?.

Here is the screen shot of the paths in resulting solution file. I can't understand how these paths carry through from the small script file? They don't exactly correspond to DCMAKE_LIBRARY_PATH so where they come from?

Project paths in visual studio project - what part of script file them come from?

How can I fix these include errors in the solution file? I tried adding these paths to Project Properites >> VC++ Directories >> 'Include Directories' but it still doesn't want to build. I am afraid even if I eliminate these include errors, I will get linker errors because the library paths are probably incorrect too. How can I fix these error and get the project to build? Thanks.

Updated question

I fixed the include error by changing the path to:

FT_INCLUDE=C:\PDF\freetype-2.4.0\include\

Now as I expected, I get lots of linker errors. However I noticed that it did created PoDoFo.lib file so now I took the tast to use this in an example demo. I got that to compile as well successfully but I get the following linker errors:

1>podofo.lib(PdfFont.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>podofo.lib(PdfDifferenceEncoding.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>podofo.lib(PdfFontSimple.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>podofo.lib(PdfIdentityEncoding.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>podofo.lib(PdfFontTrueType.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>podofo.lib(PdfFontMetricsObject.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>podofo.lib(PdfEncodingObjectFactory.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4

I did made sure the the dependent libraries are added in project settings along with paths but why do I still get these errors?

zar
  • 11,361
  • 14
  • 96
  • 178
  • 1
    I see `WANT_BOOST:BOOL=0` in your bat script - shouldn't that be a `1` if you need boost? And does `ft2build.h` actually exist inside `C:\PDF\freetype-2.4.0\include\freetype`? – Fraser Nov 20 '13 at 09:14
  • Yes it should be 1 to enable boost but I disabled it so I have one less library to worry about but I would like for boost to work as well. And yes `ft2build.h`does exist at `C:\PDF\freetype-2.4.0\include\freetype`. Part of the mystry (to me) is that I had to add the line `-DFREETYPE_INCLUDE_DIR=%FT_INCLUDE%` to build the cmake file even though `%FT_INCLUDE%` is added to `CMAKE_INCLUDE_PATH` but that alone has no effect. Without that it doesn't build. What is `CMAKE_INCLUDE_PATH` for than? Again very less documentation on these variables if anything. – zar Nov 20 '13 at 14:47

1 Answers1

0

Instead of using nmake directly, I'd recommend you use cmake-gui for building PoDoFo. Don't write your own build.cmd as this doesn't work in most cases. Note : The method described below uses your method, don't follow it. Use cmake-gui (If you don't know how exactly cmake or nmake works).

Well I will recommend you go to this site and find the references: Building static podofo with MSVS 2012 Well I guess this should work for Visual Studio 2010. Remember :

Building the prerequisite libraries - This site has also links about how to go on building these libraries. However, I assume you have already built them. However I would recommend building them again according to this tutorial.

Instructions : Do as he says. Don't miss any options regarding preprocessor definitions, runtime libraries and all the parameters same. If you miss anything or do something wrong that will force you to restart from where you started.

Errors : I myself experienced many errors while following the same procedure and this site provides no explanation. Common errors include:

Unresolved externals (either with msvcrt.lib or libcmt.lib). In that case, just go to Linker>Input>Ignore specific libraries and name that library there to just ignore it. There will be random errors sometimes. I would suggest looking up Stack Overflow itself or MSDN or Google, because after starting off with >2500 errors I was finally able to build a static library.

Last Resort: If everything fails, just contact me (if you are still interested!).