VS下PDF开发库PODOFO的安装编译、cmake使用的超详细说明

wxleasyland@sina.com

2020.5

 

用WIN7 X64,VS2012。

 

参考了https://blog.csdn.net/zxxSsdsd/article/details/9454629

 

一、依赖库:

freetype

简要:在“主目录”\builds\windows\vc2010 ,VS2012用这个目录的sln,选成release static方式, 这时就是变成生成lib,“多线程/MT”,生成freetype.lib。

 

libjpeg

简要:按install.txt说的,运行“VS2012 开发人员命令提示”,进入lijpeg目录,运行:NMAKE /f makefile.vs setup-v16,  打开生成的jpeg.sln,把“平台工具集”改成visual studio 2012(v110),按默认release、静态库lib、“MT”生成jpeg.lib。

 

libtiff

简要:从GnuWin32直接下Developer files,就是lib库文件,直接用头文件和libtiff.lib。

 

libpng

简要:vs2012打开“主目录”/projects/vstudio/vstudio.sln,里面已经有zlib了,可以用这里的zlib。选成“release library”,即按静态库方式生成libpng16.lib,“/MT”。 如果出错“警告被视为错误”,则属性->配置属性->c/c++->常规,将“警告视为错误”的选项改为“否”。

 

zlib 

简要:运行“VS2012 开发人员命令提示”,进入zlib-1.2.11目录下,运行:nmake -f win32\Makefile.msc LDFLAGS="-release",即可生成文件,静态库是zlib.lib、zlib.pdb。  不用命令行的话,也可以从contrib/vstudio/目录里选相应版本用VS打开进行编译。readme里有说明。

 

cppunit (optional)     不管

fontconfig (Linux/Unix only)     //windows可不管

Lua 5.1 (optional, only for podofoimpose Lua imposition plans)   //windows可不管

 

然后做podofo 0.9.6库。

podofo文件是按linux的回车,回车格式与windwos不一样!  没关系,可以不用修正过来。

 

podofo基本每个目录都有一个cmake的脚本文件CMakeLists.txt。

主目录的CMakeLists.txt,对应的是整个工程的所有项目。可以把所有子目录的项目全部转换出来。

子目录的CMakeLists.txt,对应的就是当前目录项目及子目录的项目。

只能对主目录的CMakeLists.txt进行转换,不能对子目录的CMakeLists.txt进行转换,否则cmake提示出错。

 

 

如果只对src\CMakeLists.txt进行转换,则会提示:

CMake Error at CMakeLists.txt:4 (MESSAGE): Run cmake on the CMakeLists.txt in the project root, not the one in the 'src' directory.  You will need to delete CMakeCache.txt from the current directory.

 

 

 

二、使用cmake gui界面版

(1)cmake界面版的使用方法

where is the source code目录:就是 CMakeLists.txt 所在的目录,可以把CMakeLists.txt拖进来,则这个目录就自动填上去了。

 

where to build the binaries目录:就是generate生成的项目文件会放在这里,我们要自己建一个空文件夹,再把目录指定到这个空文件夹。

 

下面的NAME、VALUE那里就是“参数栏”:  “参数”这里是叫entry,可以自已add entry、remove entry。

 

一般选中“Grouped”框、“Advanced”框

“Grouped”框 是把相同前缀的参数 放在一组。比如C_A、C_B就属于同一组,就会显示在一个组C里,这样容易看。

“Advanced”框 是显示高级参数,不选它,则一些高级参数不会显示出来。

 

configure:可以配置按哪个版本的VS来生成,然后就会自动开始配置,配置成功会显示“Configuring done”。

 

generate:就是转换生成出项目文件。在配置成功后,点这个,就可以生成项目文件了。

 

cmake 在配置时,会把找到的参数显示到“参数栏”里。我们可以对参数进行修改,或打勾等

在遇到错误,就会停止,一般这时是参数值错误,比如ZLIB_INCLUDE_DIR参数没有值,显示NOTFOUND,我们把值填上去后,再点“configure”或“generate”,就会继续。直到配置完成,显示“Configuring done”。

 

点generate进行生成,直到下面显示框显示“Generating done”,这样就成功了,目标文件夹里有生成的项目文件了。

 

我是这样设置参数:

 

FREETYPE_INCLUDE_DIR_FT2BUILD 为 E:/developer/freetype
FREETYPE_INCLUDE_DIR_FTHEADER 为 E:/developer/freetype
FREETYPE_LIBRARY_DEBUG 为 E:/developer/freetype
FREETYPE_LIBRARY_RELEASE 为 E:/developer/freetype

LIBJPEG_INCLUDE_DIR 为 E:/developer/libjpeg
LIBJPEG_LIBRARY_DEBUG 为 E:/developer/libjpeg
LIBJPEG_LIBRARY_RELEASE 为 E:/developer/libjpeg

PNG_PNG_INCLUDE_DIR 为 E:/developer/libpng
PNG_LIBRARY_DEBUG 为 E:/developer/libpng
PNG_LIBRARY_RELEASE  为 E:/developer/libpng

TIFF_INCLUDE_DIR 为 E:/developer/libtiff
TIFF_LIBRARY_DEBUG 为 E:/developer/libtiff
TIFF_LIBRARY_RELEASE 为 E:/developer/libtiff

ZLIB_INCLUDE_DIR 为 E:/developer/zlib
ZLIB_LIBRARY_DEBUG 为 E:/developer/zlib
ZLIB_LIBRARY_RELEASE 为 E:/developer/zlib

 

运行提示如下:

The C compiler identification is MSVC 17.0.61030.0

The CXX compiler identification is MSVC 17.0.61030.0

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Detecting C compile features

Detecting C compile features - done

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

Detecting CXX compiler ABI info

Detecting CXX compiler ABI info - done

Detecting CXX compile features

Detecting CXX compile features - done

WANT_LIB64 unset; assuming normal library directory names

Will install libraries to C:/Program Files (x86)/PoDoFo/lib

Found zlib headers in E:/developer/zlib, library at optimized;E:/developer/zlib;debug;E:/developer/zlib

 

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

 

Could NOT find LIBCRYPTO (missing: LIBCRYPTO_LIBRARY LIBCRYPTO_INCLUDE_DIR)

OpenSSL's libCrypto not found. Encryption support will be disabled

 

Could NOT find LIBIDN (missing: LIBIDN_LIBRARY LIBIDN_INCLUDE_DIR)

Libidn not found. AES-256 Encryption support will be disabled

 

Found LIBJPEG: optimized;E:/developer/libjpeg;debug;E:/developer/libjpeg 

Found libjpeg headers in E:/developer/libjpeg, library at optimized;E:/developer/libjpeg;debug;E:/developer/libjpeg

Found TIFF: optimized;E:/developer/libtiff;debug;E:/developer/libtiff 

Found libtiff headers in E:/developer/libtiff, library at optimized;E:/developer/libtiff;debug;E:/developer/libtiff

Found PNG: E:/developer/libpng (found version "1.6.37")

Found LibPng headers in E:/developer/libpng;E:/developer/zlib, library at E:/developer/libpng;optimized;E:/developer/zlib;debug;E:/developer/zlib

Could NOT find UNISTRING (missing: UNISTRING_INCLUDE_DIR UNISTRING_LIBRARY)

LibUnistring not found. Unistring support will be disabled

Ensure you cppunit installed version is at least 1.12.0

Cppunit not found. No unit tests will be built.

OpenSSL: Could not find the debug and release version of openssl

OpenSSL: Disabling OpenSSL

Found freetype library at optimized;E:/developer/freetype;debug;E:/developer/freetype, headers E:/developer/freetype

CMake Warning (dev) at cmake/modules/FindLIBSTLPORT.cmake:12 (SET):

  implicitly converting 'BOOLEAN' to 'STRING' type.

Call Stack (most recent call first):

  CMakeLists.txt:404 (FIND_PACKAGE)

This warning is for project developers.  Use -Wno-dev to suppress it.

 

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Could NOT find Fontconfig (missing: FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)

Could NOT find Lua50 (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

Could NOT find Lua (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

Lua not found - PoDoFoImpose and PoDoFoColor will be built without Lua support

Building multithreaded version of PoDoFo.

Looking for pthread.h

Looking for pthread.h - not found

Found Threads: TRUE 

Building shared PoDoFo library

Pkg-config not found. No pkg-config file will be created.

Configuring done

 

WARNING: Target "podofo_shared" requests linking to directory "E:/developer/zlib".  Targets may link only to libraries.  CMake is dropping the item.

WARNING: Target "podofo_shared" requests linking to directory "E:/developer/libjpeg".  Targets may link only to libraries.  CMake is dropping the item.

WARNING: Target "podofo_shared" requests linking to directory "E:/developer/freetype".  Targets may link only to libraries.  CMake is dropping the item.

WARNING: Target "podofo_shared" requests linking to directory "E:/developer/libpng".  Targets may link only to libraries.  CMake is dropping the item.

WARNING: Target "podofo_shared" requests linking to directory "E:/developer/libtiff".  Targets may link only to libraries.  CMake is dropping the item.

 

。。。。。。

 

Generating done

 

一大堆警告,不知所云,但还是成功了。

 

这样生成项目解决方案PoDoFo.sln,打开后看,是全部的项目都集中在一起了(podofo项目、例子项目等),34个项目,非常多。大部分例子项目都生成出来了,只有少数几个没有生成出来。

podofo_shared就是podofo库dll项目,其它的都是例子项目。

 

 

(2)VS打开后的编译问题:

 

改成release方式,编译整个解决方案。

 

CreationTest项目,有一个文件提示要保存成unicode才行,并且说字符串内有换行符:

podofo-0.9.6\test\CreationTest\CreationTest.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失

podofo-0.9.6\test\CreationTest\CreationTest.cpp(52): error C2001: 常量中有换行符

看了一下,是一个日语字串:

PdfString sJap(reinterpret_cast<const pdf_utf8*>("「PoDoFo」は今から日本語も話せます。"));

WINHEX看了一下,原文件内容是按UTF8编码的,文件头没有带UTF8 BOM。

把文件另存成UTF8,不行,一样。

另存成UNICODE(代码页1200),OK,可以了。

 

 

podofo是“podofo_shared”项目,是动态库!是生成podofo.dll文件。

然后,podofo.dll没有生成,提示链接时找不到lib文件,因为链接器属性\输入\附加依赖项里,没有写上相关依赖库的lib,自己加上,再编译,就成功了。(这就是生成时出现警告的原因

 

 

(3)问题解决

其实上面在cmake中输入的参数不太对,ZLIB_INCLUDE_DIR参数是一个PATH类型,值是一个目录路径。

而ZLIB_LIBRARY_DEBUG、ZLIB_LIBRARY_RELEASE 参数是一个FILEPATH类型,值是一个文件的全路径,比如E:/developer/zlib/zlib.lib。

这样才不会出现上面的链接找不到lib的问题。

如果输入的只是一个路径,则就会出现上面的cmake警告,并且VS编译链接时找不到lib。

 

 

下面再用cmake命令行试试。

 

 

 

三、使用cmake命令行

 

(1)用命令行cmake:

cmake命令会自动找到Visual Studio 11 2012,可以不指定VS版本。

 

同样,不能单独对子目录里的CMakeLists.txt进行转换,否则提示出错。

 

在主目录下建一个wwwww目录,cmd进入这个目录,再运行“cmake ..”

 

CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):

  Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)

Call Stack (most recent call first):

  C:/Program Files (x86)/CMake/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)

  cmake/modules/FindZLIB.cmake:47 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)

  CMakeLists.txt:315 (FIND_PACKAGE)

 

 

用findstr命令,发现

cmake\modules\FindFREETYPE.cmake

cmake\modules\FindLIBCRYPTO.cmake

cmake\modules\FindLIBIDN.cmake

cmake\modules\FindLIBJPEG.cmake

cmake\modules\FindTIFF.cmake

cmake\modules\FindZLIB.cmake

这些文件里含有“_LIBRARY_NAMES字串。这些文件是给cmake用来查找各个依赖库的。

 

另外,居然没有png库的相关文件,png库不是必须的?但运行cmake界面版时是有的,而且readme里说的PODOFO的依赖图里有,奇怪了。后面发现cmake会自动查找png库的。

 

 

我把依赖库的.h和.lib文件放在各个插件的同一个目录,比如e:\developer\XXX。

在podofo主目录下建一个空文件夹,cmd进入这个目录。

再按readme.html中的说法,我做了修改,采用以下命令:

del cmakecache.txt

set FTDIR=e:\developer\freetype

set JPEGDIR=e:\developer\libjpeg

set PNGDIR=e:\developer\libpng

set TIFFDIR=e:\developer\libtiff

set ZLIBDIR=e:\developer\zlib

cmake  ..  -DCMAKE_INCLUDE_PATH="%FTDIR%;%JPEGDIR%;%PNGDIR%;%TIFFDIR%;%ZLIBDIR%"  -DCMAKE_LIBRARY_PATH="%FTDIR%;%JPEGDIR%;%PNGDIR%;%TIFFDIR%;%ZLIBDIR%"  -DPODOFO_BUILD_SHARED:BOOL=FALSE  -DFREETYPE_LIBRARY_NAMES=freetype  -DLIBJPEG_LIBRARY_NAMES=jpeg  -DTIFF_LIBRARY_NAMES=libtiff  -DZLIB_LIBRARY_NAMES=zlib

 

..  表示cmakelists.txt文件是在父目录中。

 

-D 指定的参数 就是 等于 “cmake界面版” 里的entry

 

CMAKE_INCLUDE_PATH、CMAKE_LIBRARY_PATH 参数指定了cmake公共的包含目录、库目录,这样查找模块在查找时,就会自动找到各个依赖库的包含文件、库文件!

 

PODOFO_BUILD_SHARED:BOOL=FALSE  使得编译出来是静态库lib,不是dll。

 

其它用-D来指定库名称,我的lib文件各自名称是freetype.lib,jpeg.lib,libtiff.lib,zlib.lib。

 

 

运行结果如下:

-- Building for: Visual Studio 11 2012      --自动会找到VS2012

-- The C compiler identification is MSVC 17.0.61030.0

-- The CXX compiler identification is MSVC 17.0.61030.0

-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

WANT_LIB64 unset; assuming normal library directory names Will install libraries to C:/Program Files (x86)/PoDoFo/lib

-- Looking for strings.h

-- Looking for strings.h - not found

-- Looking for arpa/inet.h

-- Looking for arpa/inet.h - not found

-- Looking for winsock2.h

-- Looking for winsock2.h - found

-- Looking for mem.h

-- Looking for mem.h - not found

-- Looking for ctype.h

-- Looking for ctype.h - found

-- Looking for sys/types.h

-- Looking for sys/types.h - found

-- Looking for stdint.h

-- Looking for stdint.h - found

-- Looking for BaseTsd.h

-- Looking for BaseTsd.h - found

-- Looking for sys/types.h

-- Looking for sys/types.h - found

-- Looking for stdint.h

-- Looking for stdint.h - found

-- Looking for stddef.h

-- Looking for stddef.h - found

-- Check size of long int

-- Check size of long int - done

-- Check size of int64_t

-- Check size of int64_t - done

-- Check if the system is big endian

-- Searching 16 bit integer

-- Check size of unsigned short

-- Check size of unsigned short - done

-- Using unsigned short

-- Check if the system is big endian - little endian

 

-- Found ZLIB: E:/developer/zlib/zlib.lib

Found zlib headers in E:/developer/libpng, library at E:/developer/zlib/zlib.lib

 

-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

-- Could NOT find LIBCRYPTO (missing: LIBCRYPTO_LIBRARY LIBCRYPTO_INCLUDE_DIR)

OpenSSL's libCrypto not found. Encryption support will be disabled

 

-- Could NOT find LIBIDN (missing: LIBIDN_LIBRARY LIBIDN_INCLUDE_DIR)

Libidn not found. AES-256 Encryption support will be disabled

 

-- Found LIBJPEG: E:/developer/libjpeg/jpeg.lib

Found libjpeg headers in E:/developer/libjpeg, library at E:/developer/libjpeg/jpeg.lib

 

-- Found TIFF: E:/developer/libtiff/libtiff.lib

Found libtiff headers in E:/developer/libtiff, library at E:/developer/libtiff/libtiff.lib

 

-- Found ZLIB: E:/developer/zlib/zlib.lib (found version "1.2.11")

 

-- Found PNG: E:/developer/libpng/libpng16.lib (found version "1.6.37")

Found LibPng headers in E:/developer/libpng;E:/developer/libpng, library at E:/developer/libpng/libpng16.lib;E:/developer/zlib/zlib.lib

--会自动找到PNG的库!说明还是需要png库,只要给出目录就行!

 

-- Could NOT find UNISTRING (missing: UNISTRING_INCLUDE_DIR UNISTRING_LIBRARY)

LibUnistring not found. Unistring support will be disabled

 

-- Ensure you cppunit installed version is at least 1.12.0

Cppunit not found. No unit tests will be built.

 

OpenSSL: Could not find the debug and release version of openssl

OpenSSL: Disabling OpenSSL

 

Found freetype library at E:/developer/freetype/freetype.lib, headers E:/developer/freetype

 

CMake Warning (dev) at cmake/modules/FindLIBSTLPORT.cmake:12 (SET):

  implicitly converting 'BOOLEAN' to 'STRING' type.

Call Stack (most recent call first):

  CMakeLists.txt:404 (FIND_PACKAGE)

This warning is for project developers.  Use -Wno-dev to suppress it.

 

-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

-- Could NOT find Fontconfig (missing: FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)

-- Could NOT find Lua50 (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

-- Could NOT find Lua (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

Lua not found - PoDoFoImpose and PoDoFoColor will be built without Lua support

 

Building multithreaded version of PoDoFo.

-- Looking for pthread.h

-- Looking for pthread.h - not found

-- Found Threads: TRUE

 

Building static PoDoFo library

-- Configuring done

-- Generating done

-- Build files have been written to: F:/MYXPfold/myDESK/PODOFO可读写PDF的库/podofo-0.9.6/wwwww

 

成功!

 

 

(2)VS2012打开podofo.sln:

改成release方式。

 

podofo是“podofo_static”项目,是静态库,是生成podofo.lib!编译后,有src\Release\podofo.lib文件!

 

例子项目 比如helloworld项目里,链接器属性\输入\附加依赖项里,有:

podofo.lib;E:\developer\zlib\zlib.lib;E:\developer\libjpeg\jpeg.lib; E:\developer\freetype\freetype.lib;E:\developer\libpng\libpng16.lib; E:\developer\libtiff\libtiff.lib;

所以会把lib链接进来。 这里已经指定路径名了,所以在VC++目录属性中就不用加上目录路径。

 

同样,CreationTest.cpp文件有编码问题。

 

还有一个失败项目:WatermarkTest, 是因为podofo-0.9.6/test/TokenizerTest/objects这个文件夹不存在,属于源库包就有问题,那就不管这个项目了。 

 

成功!

 

 

 

(3)cmake查找png库的原理

podofo主目录的cmakelists.txt中,有:

FIND_PACKAGE(ZLIB REQUIRED)

FIND_PACKAGE(LIBJPEG)

FIND_PACKAGE(TIFF)

FIND_PACKAGE(Png)

FIND_PACKAGE(FREETYPE REQUIRED)

这些命令是让cmake从cmake\modules下去找相应模块文件去执行:

FindZLIB.cmake

FindLIBJPEG.cmake

FindTIFF.cmake

FindFREETYPE.cmake

但目录里面没有FindPng.cmake这个文件,那png库是怎么找到的?

 

后来知道了,在cmake自己的安装程序中,有FindPNG.cmake这个文件:

"C:\Program Files (x86)\CMake\share\cmake-3.15\Modules\FindPNG.cmake"

所以podofo中就没有带这个模块文件了,采用cmake自己的就可以。

 

 

(4)cmake界面版 按 命令行参数 去生成

人工输入entry为:

CMAKE_INCLUDE_PATH为e:\developer\freetype;e:\developer\libjpeg;e:\developer\libpng;e:\developer\libtiff;e:\developer\zlib

CMAKE_LIBRARY_PATH为e:\developer\freetype;e:\developer\libjpeg;e:\developer\libpng;e:\developer\libtiff;e:\developer\zlib

PODOFO_BUILD_SHARED为BOOL型,FALSE 

FREETYPE_LIBRARY_NAMES为freetype 

LIBJPEG_LIBRARY_NAMES为jpeg 

TIFF_LIBRARY_NAMES为libtiff 

ZLIB_LIBRARY_NAMES为zlib

 

cmake运行提示:

The C compiler identification is MSVC 17.0.61030.0

The CXX compiler identification is MSVC 17.0.61030.0

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Detecting C compile features

Detecting C compile features - done

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

Detecting CXX compiler ABI info

Detecting CXX compiler ABI info - done

Detecting CXX compile features

Detecting CXX compile features - done

WANT_LIB64 unset; assuming normal library directory names

Will install libraries to C:/Program Files (x86)/PoDoFo/lib

Looking for strings.h

Looking for strings.h - not found

Looking for arpa/inet.h

Looking for arpa/inet.h - not found

Looking for winsock2.h

Looking for winsock2.h - found

Looking for mem.h

Looking for mem.h - not found

Looking for ctype.h

Looking for ctype.h - found

Looking for sys/types.h

Looking for sys/types.h - found

Looking for stdint.h

Looking for stdint.h - found

Looking for BaseTsd.h

Looking for BaseTsd.h - found

Looking for sys/types.h

Looking for sys/types.h - found

Looking for stdint.h

Looking for stdint.h - found

Looking for stddef.h

Looking for stddef.h - found

Check size of long int

Check size of long int - done

Check size of int64_t

Check size of int64_t - done

Check if the system is big endian

Searching 16 bit integer

Check size of unsigned short

Check size of unsigned short - done

Using unsigned short

Check if the system is big endian - little endian

Found ZLIB: E:/developer/zlib/zlib.lib 

Found zlib headers in E:/developer/libpng, library at E:/developer/zlib/zlib.lib

 

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Could NOT find LIBCRYPTO (missing: LIBCRYPTO_LIBRARY LIBCRYPTO_INCLUDE_DIR)

OpenSSL's libCrypto not found. Encryption support will be disabled

 

Could NOT find LIBIDN (missing: LIBIDN_LIBRARY LIBIDN_INCLUDE_DIR)

Libidn not found. AES-256 Encryption support will be disabled

 

Found LIBJPEG: E:/developer/libjpeg/jpeg.lib 

Found libjpeg headers in E:/developer/libjpeg, library at E:/developer/libjpeg/jpeg.lib

Found TIFF: E:/developer/libtiff/libtiff.lib 

Found libtiff headers in E:/developer/libtiff, library at E:/developer/libtiff/libtiff.lib

Found ZLIB: E:/developer/zlib/zlib.lib (found version "1.2.11")

Found PNG: E:/developer/libpng/libpng16.lib (found version "1.6.37")

Found LibPng headers in E:/developer/libpng;E:/developer/libpng, library at E:/developer/libpng/libpng16.lib;E:/developer/zlib/zlib.lib

Could NOT find UNISTRING (missing: UNISTRING_INCLUDE_DIR UNISTRING_LIBRARY)

LibUnistring not found. Unistring support will be disabled

Ensure you cppunit installed version is at least 1.12.0

Cppunit not found. No unit tests will be built.

 

OpenSSL: Could not find the debug and release version of openssl

OpenSSL: Disabling OpenSSL

 

Found freetype library at E:/developer/freetype/freetype.lib, headers E:/developer/freetype

CMake Warning (dev) at cmake/modules/FindLIBSTLPORT.cmake:12 (SET):

  implicitly converting 'BOOLEAN' to 'STRING' type.

Call Stack (most recent call first):

  CMakeLists.txt:404 (FIND_PACKAGE)

This warning is for project developers.  Use -Wno-dev to suppress it.

 

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Could NOT find Fontconfig (missing: FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)

Could NOT find Lua50 (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

Could NOT find Lua (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

Lua not found - PoDoFoImpose and PoDoFoColor will be built without Lua support

Building multithreaded version of PoDoFo.

Looking for pthread.h

Looking for pthread.h - not found

Found Threads: TRUE 

Building static PoDoFo library

Configuring done

Generating done

 

成功,就是和命令行效果一样的。

 

 

 

 

 

四、使用/MT、/MD进行编译的结果

 

  1. PODOFO.dll项目(podofo_shared)  ,/MD

成功,提示:

2>LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

 

后面改成用静态库lib,这个动态库dll就不用了。

 

  1. PODOFO.lib项目(podofo_static)  ,/MT

成功有17MB,提示:

2>  正在生成代码...

2>  podofo_static.vcxproj -> F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\src\Release\podofo.lib

 

没有进行link,所以没有链接错误。

改名成podofo_mt.lib,放在E:\developer\podofo\。

 

lib文件里含有:

/FAILIFMISMATCH:"_MSC_VER=1700" /FAILIFMISMATCH:"_ITERATOR_DEBUG_LEVEL=0" /FAILIFMISMATCH:"RuntimeLibrary=MT_StaticRelease" /DEFAULTLIB:"libcpmt"

还含有:

/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES"

 

 

  1. PODOFO.lib项目(podofo_static)  ,/MD

成功有14MB,提示:

2>  正在生成代码...

2>  podofo_static.vcxproj -> F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\src\Release\podofo.lib

 

没有进行link,所以没有链接错误。

改名成podofo_md.lib,放在E:\developer\podofo\。

 

lib文件里含有:

/FAILIFMISMATCH:"_MSC_VER=1700" /FAILIFMISMATCH:"_ITERATOR_DEBUG_LEVEL=0" /FAILIFMISMATCH:"RuntimeLibrary=MD_DynamicRelease" /DEFAULTLIB:"msvcprt"

还含有:

/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES"

 

 

  1. HELLOWORLD.exe项目   ,/MD   (项目依赖项是podofo)

(PODOFO.lib  ,/MD)

 

成功:

2>  正在生成代码...

2>  podofo_static.vcxproj -> F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\src\Release\podofo.lib

3>------ 已启动全部重新生成: 项目: helloworld, 配置: Release Win32 ------

3>  Building Custom Rule F:/MYXPfold/myDESK/PODOFO可读写PDF的库/podofo-0.9.6/examples/helloworld/CMakeLists.txt

3>  helloworld.cpp

3>  jpeg.lib(jerror.obj) : 找到 MSIL .netmodule 或使用 /GL 编译的模块;正在使用 /LTCG 重新启动链接;将 /LTCG 添加到链接命令行以改进链接器性能

3>LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

3>  正在生成代码

3>  已完成代码的生成

3>  helloworld.vcxproj -> F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\examples\helloworld\Release\helloworld.exe

 

 

  1. HELLOWORLD.exe项目   ,/MD    (项目依赖项是podofo)

(PODOFO.lib  ,/MT

 

失败,提示:

2>  正在生成代码...

2>  podofo_static.vcxproj -> F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\src\Release\podofo.lib

 

3>------ 已启动全部重新生成: 项目: helloworld, 配置: Release Win32 ------

3>  Building Custom Rule F:/MYXPfold/myDESK/PODOFO可读写PDF的库/podofo-0.9.6/examples/helloworld/CMakeLists.txt

3>  helloworld.cpp

3>podofo.lib(PdfError.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(helloworld.obj 中)

。。。N多个

3>LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

3>LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

 

3>F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\examples\helloworld\Release\helloworld.exe : fatal error LNK1319: 检测到 82 个不匹配项

 

所以PODOFO.lib项目 和 HELLOWORLD.exe项目 的编译开关/MD或/MT需要一致。

 

 

 

  1. HELLOWORLD.exe项目   ,/MD  

删掉podofo项目

链接器输入中指定E:\developer\podofo\podofo_mt.lib

 

失败,提示:

2>------ 已启动全部重新生成: 项目: helloworld, 配置: Release Win32 ------

2>  Building Custom Rule F:/MYXPfold/myDESK/PODOFO可读写PDF的库/podofo-0.9.6/examples/helloworld/CMakeLists.txt

2>  helloworld.cpp

2>podofo_mt.lib(PdfError.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(helloworld.obj 中)

。。。N多个

2>LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

2>LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

2>F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\examples\helloworld\Release\helloworld.exe : fatal error LNK1319: 检测到 82 个不匹配项

 

 

 

  1. HELLOWORLD.exe项目  ,/MD  

删掉podofo项目

链接器输入中指定E:\developer\podofo\podofo_md.lib

 

成功,提示:

2>  jpeg.lib(jerror.obj) : 找到 MSIL .netmodule 或使用 /GL 编译的模块;正在使用 /LTCG 重新启动链接;将 /LTCG 添加到链接命令行以改进链接器性能

2>LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

2>  正在生成代码

2>  已完成代码的生成

2>  helloworld.vcxproj -> F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\wwwww\examples\helloworld\Release\helloworld.exe

 

 

所以ELLOWORLD.exe项目 和 引用的podofo.lib  的编译开关/MD或/MT需要一致。

 

 

podofo.dll项目链接时,没有发生error LNK2038错误,是因为zlib.lib等依赖库没有触发“/FAILIFMISMATCH:"RuntimeLibrary=”字串,所以不用强制匹配检查。

 

 

 

五、加入openSSL支持加密解密

 

发现podofoencrypt项目,EXE运行时,无法对PDF文件加密操作,提示错误:

Error: An error 50 ocurred during encrypting the pdf file.

PoDoFo encountered an error. Error: 50 ePdfError_NotCompiled

        Error Description: This feature was disabled during compile time.

        Callstack:

        #0 Error Source: F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6\src\base\PdfEncrypt.cpp:2179

            Information: PdfEncrypt::CreatePdfEncrypt:   Encryption support was disabled during compile time

 

就是PODOFO库在编译时,没有SSL库,故没有SSL功能。

 

 

1. 可以预先在CMakeLists.txt文件中,加入参数entry

 

cmake gui界面比较直观,还是继续采用界面版吧,但是每次都要输入entry参数,太麻烦。

 

为了方便cmake界面使用,不要每次都add entry,可以预先在CMakeLists.txt文件中,加入参数entry。比如按上面的参数,加在PROJECT(PoDoFo)后面

SET(CMAKE_INCLUDE_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

SET(CMAKE_LIBRARY_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

 

SET(PODOFO_BUILD_SHARED  FALSE  CACHE BOOL  "")

SET(FREETYPE_LIBRARY_NAMES  "freetype" CACHE STRING "")

SET(LIBJPEG_LIBRARY_NAMES  "jpeg" CACHE STRING "")

SET(TIFF_LIBRARY_NAMES  "libtiff" CACHE STRING "")

SET(ZLIB_LIBRARY_NAMES  "zlib" CACHE STRING "")

 

 

BOOL类型,值为OFF、FALSE、乱七八糟的值,均是FALSE,不打勾。

BOOL类型,值为ON、TRUE,均是TRUE,会打勾。

 

字串里面,\不是\,而是带格式解析,所以路径要用/,不能用\,否则出错,比如提示:

Invalid escape sequence \d

  Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run

  "cmake --help-policy CMP0010" for policy details.  Use the cmake_policy

  command to set the policy and suppress this warning.

 

 

2. 加上openSSL1.1.1g支持

 

从slproweb.com下载openSSL的win版,下载Win32 OpenSSL v1.1.1g,文件比较大的那个(因为里面有VC调试文件,所以文件很大)。

 

VC版的lib在安装目录如C:/Program Files (x86)/OpenSSL-Win32/lib/VC下,有libcrypto32MD.lib、libssl32MD.lib等。

头文件包含目录在如C:/Program Files (x86)/OpenSSL-Win32/include,注意不用再加上openssl子目录

 

cmake\modules\FindOpenSSL.cmake,这个模块是查找openssl的,必须要同时找到debug和release版,才能通过。

cmake\modules\FindLIBCRYPTO.cmake,这个模块是查找libcrypto的。

 

 

CMakeLists.txt文件中,加入这些参数entry:

SET(CMAKE_INCLUDE_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib;C:/Program Files (x86)/OpenSSL-Win32/include" CACHE STRING "")

SET(CMAKE_LIBRARY_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

 

SET(PODOFO_BUILD_SHARED  FALSE CACHE BOOL  "")

SET(FREETYPE_LIBRARY_NAMES  "freetype" CACHE STRING "")

SET(LIBJPEG_LIBRARY_NAMES  "jpeg" CACHE STRING "")

SET(TIFF_LIBRARY_NAMES  "libtiff" CACHE STRING "")

SET(ZLIB_LIBRARY_NAMES  "zlib" CACHE STRING "")

 

SET(LIBCRYPTO_LIBRARY_DEBUG "C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libcrypto32MDd.lib" CACHE FILEPATH "")

SET(LIBCRYPTO_LIBRARY_RELEASE "C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libcrypto32MD.lib" CACHE FILEPATH "")

SET(SSL_EAY_DEBUG "C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libssl32MDd.lib" CACHE FILEPATH "")

SET(SSL_EAY_RELEASE "C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libssl32MD.lib" CACHE FILEPATH "")

 

cmake运行结果如下:

The C compiler identification is MSVC 17.0.61030.0

The CXX compiler identification is MSVC 17.0.61030.0

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Detecting C compile features

Detecting C compile features - done

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/cl.exe -- works

Detecting CXX compiler ABI info

Detecting CXX compiler ABI info - done

Detecting CXX compile features

Detecting CXX compile features - done

 

WANT_LIB64 unset; assuming normal library directory names

Will install libraries to C:/Program Files (x86)/PoDoFo/lib

 

Looking for strings.h

Looking for strings.h - not found

Looking for arpa/inet.h

Looking for arpa/inet.h - not found

Looking for winsock2.h

Looking for winsock2.h - found

Looking for mem.h

Looking for mem.h - not found

Looking for ctype.h

Looking for ctype.h - found

Looking for sys/types.h

Looking for sys/types.h - found

Looking for stdint.h

Looking for stdint.h - found

Looking for BaseTsd.h

Looking for BaseTsd.h - found

Looking for sys/types.h

Looking for sys/types.h - found

Looking for stdint.h

Looking for stdint.h - found

Looking for stddef.h

Looking for stddef.h - found

Check size of long int

Check size of long int - done

Check size of int64_t

Check size of int64_t - done

Check if the system is big endian

Searching 16 bit integer

Check size of unsigned short

Check size of unsigned short - done

Using unsigned short

Check if the system is big endian - little endian

Found ZLIB: E:/developer/zlib/zlib.lib

Found zlib headers in E:/developer/libpng, library at E:/developer/zlib/zlib.lib

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

 

Found LIBCRYPTO: optimized;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libcrypto32MD.lib;debug;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libcrypto32MDd.lib

Performing Test PODOFO_HAVE_OPENSSL_1_1

Performing Test PODOFO_HAVE_OPENSSL_1_1 - Success

Performing Test PODOFO_HAVE_OPENSSL_NO_RC4

Performing Test PODOFO_HAVE_OPENSSL_NO_RC4 - Failed

 

Found OpenSSL's libCrypto headers in C:/Program Files (x86)/OpenSSL-Win32/include, library at optimized;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libcrypto32MD.lib;debug;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libcrypto32MDd.lib

 

Could NOT find LIBIDN (missing: LIBIDN_LIBRARY LIBIDN_INCLUDE_DIR)

Libidn not found. AES-256 Encryption support will be disabled

 

Found LIBJPEG: E:/developer/libjpeg/jpeg.lib

Found libjpeg headers in E:/developer/libjpeg, library at E:/developer/libjpeg/jpeg.lib

Found TIFF: E:/developer/libtiff/libtiff.lib

Found libtiff headers in E:/developer/libtiff, library at E:/developer/libtiff/libtiff.lib

Found ZLIB: E:/developer/zlib/zlib.lib (found version "1.2.11")

Found PNG: E:/developer/libpng/libpng16.lib (found version "1.6.37")

Found LibPng headers in E:/developer/libpng;E:/developer/libpng, library at E:/developer/libpng/libpng16.lib;E:/developer/zlib/zlib.lib

Could NOT find UNISTRING (missing: UNISTRING_INCLUDE_DIR UNISTRING_LIBRARY)

LibUnistring not found. Unistring support will be disabled

Ensure you cppunit installed version is at least 1.12.0

Cppunit not found. No unit tests will be built.

Found OpenSSL: optimized;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libssl32MD.lib;debug;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/static/libssl32MDd.lib

Found freetype library at E:/developer/freetype/freetype.lib, headers E:/developer/freetype

CMake Warning (dev) at cmake/modules/FindLIBSTLPORT.cmake:12 (SET):

implicitly converting 'BOOLEAN' to 'STRING' type.

Call Stack (most recent call first):

CMakeLists.txt:422 (FIND_PACKAGE)

This warning is for project developers. Use -Wno-dev to suppress it.

 

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Could NOT find Fontconfig (missing: FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)

Could NOT find Lua50 (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

Could NOT find Lua (missing: LUA_LIBRARIES LUA_INCLUDE_DIR)

Lua not found - PoDoFoImpose and PoDoFoColor will be built without Lua support

 

Building multithreaded version of PoDoFo.

Looking for pthread.h

Looking for pthread.h - not found

Found Threads: TRUE

 

Building static PoDoFo library

Configuring done

 

Generating done

 

 

然后VS2012编译,出错,提示:

libcrypto32MD.lib  error LNK2001: 无法解析的外部符号 ___stdio_common_vsprintf

。。。。。。

 

完蛋,是不是因为openSSL按不同版本的VS编译的,不能直接用,要自己编译openSSL才行?

不是,改成采用 DLL版(非static) 的libssl32MDd.lib,libssl32MD.lib,就可以了!使用时把dll拷到同一目录一起就行。 

因为openssl的notes.win文件说如果是静态库版,链接时还要加什么什么lib。。。才行。麻烦,就用动态版dll吧。

 

改完再编译,成功。

 

 

3.  openSSL1.1.1g 不兼容的问题

 

编译出来的exe打开一个owner密码加密的文件,会显示“Error AES-decryption data”错误,比如podofotxtextract:

F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6(2)\wwwww\tools\podofotxtextract\Release>podofotxtextract owner.pdf

<</Encrypt 12 0 R/ID[<B7D174AD30959D3D3E2B6819B6561BFD><B7D174AD30959D3D3E2B6819

B6561BFD>]/Info 5 0 R/Root 1 0 R/Size 13>>

Error: An error 8 ocurred during processing the pdf file.

PoDoFo encountered an error. Error: 8 ePdfError_InternalLogic

        Error Description: An internal error occurred.

        Callstack:

        #0 Error Source: F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6(2)\

src\base\PdfParserObject.cpp:403

                Information: Unable to parse the stream for object 4 0 obj .

        #1 Error Source: F:\MYXPfold\myDESK\PODOFO可读写PDF的库\podofo-0.9.6(2)\

src\base\PdfEncrypt.cpp:411

                Information: Error AES-decryption data

 

 

原因是podofo 0.9.6和openSSL1.1.1g不太兼容

https://sourceforge.net/p/podofo/mailman/message/36452108/说的,对PdfEncrypt.cpp进行修改,重新编译,OK了。  对于有owner加密的pdf,podofotxtextract可以正常打开了。

 

再试试改成采用openSSL1.0.2u版本的头文件和lib进行链接, OK,不需要修改PdfEncrypt.cpp,而且PATH路径中已经有其它软件的相同dll可以用,所以exe运行目录就不用把dll拷进来了。

 

所以必须使用openSSL1.0.2u才好!

 

 

4.  openSSL 和 LIBCRYPTO 是什么鬼?

 

FindOpenSSL.cmake,这个模块是查找openssl的,找的是ssleay32,这个其实是老版openSSL1.0.2u的文件。

FindLIBCRYPTO.cmake,这个模块是查找libcrypto的,这个是新版openSSL1.1.1g的?   老版openSSL没有crypto这个库。

二个模块同时存在,libcrypto不是属于openSSL的吗?这是怎么回事?

 

 

5. 试只用libcrypto 1.1.1g的LIBCRYPTO

参数如下:

SET(CMAKE_INCLUDE_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

SET(CMAKE_LIBRARY_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

 

SET(PODOFO_BUILD_SHARED  FALSE CACHE BOOL  "")

SET(FREETYPE_LIBRARY_NAMES  "freetype" CACHE STRING "")

SET(LIBJPEG_LIBRARY_NAMES  "jpeg" CACHE STRING "")

SET(TIFF_LIBRARY_NAMES  "libtiff" CACHE STRING "")

SET(ZLIB_LIBRARY_NAMES  "zlib" CACHE STRING "")

 

SET(LIBCRYPTO_INCLUDE_DIR "C:/Program Files (x86)/OpenSSL-Win32/include" CACHE PATH "")

SET(LIBCRYPTO_LIBRARY_DEBUG "C:/Program Files (x86)/OpenSSL-Win32/lib/VC/libcrypto32MDd.lib" CACHE FILEPATH "")

SET(LIBCRYPTO_LIBRARY_RELEASE "C:/Program Files (x86)/OpenSSL-Win32/lib/VC/libcrypto32MD.lib" CACHE FILEPATH "")

 

 

cmake运行如下:

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Performing Test PODOFO_HAVE_OPENSSL_1_1

Performing Test PODOFO_HAVE_OPENSSL_1_1 - Success

Performing Test PODOFO_HAVE_OPENSSL_NO_RC4

Performing Test PODOFO_HAVE_OPENSSL_NO_RC4 - Failed

Found OpenSSL's libCrypto headers in C:/Program Files (x86)/OpenSSL-Win32/include, library at optimized;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/libcrypto32MD.lib;debug;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/libcrypto32MDd.lib

 

Could NOT find LIBIDN (missing: LIBIDN_LIBRARY LIBIDN_INCLUDE_DIR)

Libidn not found. AES-256 Encryption support will be disabled

。。。

OpenSSL: Could not find the debug and release version of openssl

OpenSSL: Disabling OpenSSL

。。。

Configuring done

 

 

 

最终结果,podofoencrypt可以正常加密。但podofotxtextract运行时对于有owner加密的pdf,同样出错:

Information: Error AES-decryption data

 

把PdfEncrypt.cpp文件修改一下,OK,podofotxtextract解密正常了!

 

看来没有openSSL模块是可以的!

 

 

6. 试只用openSSL 1.0.2u的ssleay

参数如下:

SET(CMAKE_INCLUDE_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

SET(CMAKE_LIBRARY_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

 

SET(PODOFO_BUILD_SHARED  FALSE CACHE BOOL  "")

SET(FREETYPE_LIBRARY_NAMES  "freetype" CACHE STRING "")

SET(LIBJPEG_LIBRARY_NAMES  "jpeg" CACHE STRING "")

SET(TIFF_LIBRARY_NAMES  "libtiff" CACHE STRING "")

SET(ZLIB_LIBRARY_NAMES  "zlib" CACHE STRING "")

 

SET(OPENSSL_INCLUDE_DIR "C:/OpenSSL-Win32/include" CACHE PATH "")

SET(SSL_EAY_DEBUG "C:/OpenSSL-Win32/lib/VC/ssleay32MDd.lib" CACHE FILEPATH "")

SET(SSL_EAY_RELEASE "C:/OpenSSL-Win32/lib/VC/ssleay32MD.lib" CACHE FILEPATH "")

 

 

cmake运行如下:

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Could NOT find LIBCRYPTO (missing: LIBCRYPTO_LIBRARY LIBCRYPTO_INCLUDE_DIR)

OpenSSL's libCrypto not found.   Encryption support will be disabled

 

ould NOT find LIBIDN (missing: LIBIDN_LIBRARY LIBIDN_INCLUDE_DIR)

Libidn not found. AES-256 Encryption support will be disabled

。。。

Found OpenSSL: optimized;C:/OpenSSL-Win32/lib/VC/ssleay32MD.lib;debug;C:/OpenSSL-Win32/lib/VC/ssleay32MDd.lib

。。。

Configuring done

 

 

最终结果, podofotxtextract无法解密,出错:

     Information: PdfEncrypt::CreatePdfEncrypt: Encryption support was disabled during compile time

 

看来libcrypto模块是加密算法库,是必须要的。

 

 

 

7. 试采用openSSL 1.0.2u 的加密算法库libeay及ssleay

参数如下:

SET(CMAKE_INCLUDE_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

SET(CMAKE_LIBRARY_PATH  "e:/developer/freetype;e:/developer/libjpeg;e:/developer/libpng;e:/developer/libtiff;e:/developer/zlib" CACHE STRING "")

 

SET(PODOFO_BUILD_SHARED  FALSE CACHE BOOL  "")

SET(FREETYPE_LIBRARY_NAMES  "freetype" CACHE STRING "")

SET(LIBJPEG_LIBRARY_NAMES  "jpeg" CACHE STRING "")

SET(TIFF_LIBRARY_NAMES  "libtiff" CACHE STRING "")

SET(ZLIB_LIBRARY_NAMES  "zlib" CACHE STRING "")

 

SET(LIBCRYPTO_INCLUDE_DIR "C:/OpenSSL-Win32/include" CACHE PATH "")

SET(LIBCRYPTO_LIBRARY_DEBUG "C:/OpenSSL-Win32/lib/VC/libeay32MDd.lib" CACHE FILEPATH "")

SET(LIBCRYPTO_LIBRARY_RELEASE "C:/OpenSSL-Win32/lib/VC/libeay32MD.lib" CACHE FILEPATH "")

 

SET(OPENSSL_INCLUDE_DIR "C:/OpenSSL-Win32/include" CACHE PATH "")

SET(SSL_EAY_DEBUG "C:/OpenSSL-Win32/lib/VC/ssleay32MDd.lib" CACHE FILEPATH "")

SET(SSL_EAY_RELEASE "C:/OpenSSL-Win32/lib/VC/ssleay32MD.lib" CACHE FILEPATH "")

 

cmake运行如下:

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Performing Test PODOFO_HAVE_OPENSSL_1_1

Performing Test PODOFO_HAVE_OPENSSL_1_1 - Failed

Performing Test PODOFO_HAVE_OPENSSL_NO_RC4

Performing Test PODOFO_HAVE_OPENSSL_NO_RC4 - Failed

Found OpenSSL's libCrypto headers in C:/OpenSSL-Win32/include, library at optimized;C:/OpenSSL-Win32/lib/VC/libeay32MD.lib;debug;C:/OpenSSL-Win32/lib/VC/libeay32MDd.lib

 

Could NOT find LIBIDN (missing: LIBIDN_LIBRARY LIBIDN_INCLUDE_DIR)

Libidn not found. AES-256 Encryption support will be disabled

。。。

Found OpenSSL: optimized;C:/OpenSSL-Win32/lib/VC/ssleay32MD.lib;debug;C:/OpenSSL-Win32/lib/VC/ssleay32MDd.lib

。。。

Configuring done

 

 

最终结果,podofoencrypt正常加密,podofotxtextract正常解密。

 

 

所以:

openSSL在1.0.x之前的版本中,文件为libeay32和ssleay32。在1.1.x之后的版本中,名字是libcrypto和libssl。

openSSL加密算法库=老版libeay32=新版libcrypto

openSSL SSL协议库=老版ssleay32=新版libssl

PODOFO实际的加密解密是采用openSSL中的加密算法库,在PODOFO里是叫LIBCRYPTO模块,需要有这个库才有加密解密的功能!和PdfEncrypt.cpp相关。

而PODOFO里所谓的openSSL模块只是对应于openSSL中的SSL协议库,用于实现SSL协议的,和加密解密无关。

 

 

 

六、总结一下:

所有依赖库采用静态库lib,/MD,release。

openSSL库采用动态库dll,/MD,release。版本采用1.0.2u。

podofo采用静态库lib,/MD,release。

podofo的exe项目,/MD,release。

根据 五、7的参数,进行podofo所有项目的cmake gui生成。

 

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,以下是使用CMake编译安装MySQL5.7的详细步骤: 1. 下载MySQL5.7的源代码包,解压缩到任意目录,例如 /usr/local/src/mysql-5.7.33。 2. 在终端进入源代码目录,创建一个 build 目录,用于存放编译生成的文件。 ``` cd /usr/local/src/mysql-5.7.33 mkdir build cd build ``` 3. 在 build 目录中使用 CMake 生成 Makefile 文件。 ``` cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost_1_59_0 \ -DWITH_SSL=bundled \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_unicode_ci \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_DEBUG=0 \ -DWITH_EMBEDDED_SERVER=OFF \ -DWITH_LIBEVENT=system ``` 这里是一些常用的选项说明: - `-DCMAKE_INSTALL_PREFIX`:指定 MySQL 的安装目录,默认为 /usr/local/mysql。 - `-DMYSQL_DATADIR`:指定 MySQL 数据目录,默认为 /usr/local/mysql/data。 - `-DDOWNLOAD_BOOST=1`:从 MySQL 官网下载 Boost 源码。 - `-DWITH_BOOST`:指定 Boost 的路径。 - `-DWITH_SSL=bundled`:使用 MySQL 自带的 SSL 。 - `-DWITH_INNOBASE_STORAGE_ENGINE=1`:启用 InnoDB 存储引擎。 - `-DWITH_ARCHIVE_STORAGE_ENGINE=1`:启用 Archive 存储引擎。 - `-DWITH_BLACKHOLE_STORAGE_ENGINE=1`:启用 Blackhole 存储引擎。 - `-DWITH_PARTITION_STORAGE_ENGINE=1`:启用 Partition 存储引擎。 - `-DEXTRA_CHARSETS=all`:启用所有的字符集。 - `-DDEFAULT_CHARSET=utf8mb4`:设置默认字符集为 utf8mb4。 - `-DDEFAULT_COLLATION=utf8mb4_unicode_ci`:设置默认排序规则为 utf8mb4_unicode_ci。 - `-DENABLED_LOCAL_INFILE=1`:允许从本地加载数据文件。 - `-DWITH_DEBUG=0`:关闭调试模式。 - `-DWITH_EMBEDDED_SERVER=OFF`:不编译嵌入式服务器。 - `-DWITH_LIBEVENT=system`:使用系统自带的 libevent 。 4. 使用 make 命令编译源代码。 ``` make -j4 ``` 这里的 -j4 表示使用 4 个 CPU 核心进行编译,可以根据需要进行调整。 5. 使用 make 命令安装 MySQL。 ``` sudo make install ``` 6. 修改 MySQL 数据目录的权限。 ``` sudo chown -R mysql:mysql /usr/local/mysql ``` 7. 初始化 MySQL 数据。 ``` sudo /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data ``` 8. 启动 MySQL 服务。 ``` sudo /usr/local/mysql/bin/mysqld_safe --user=mysql & ``` 现在,MySQL5.7已经成功编译安装完成了。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值