编译skia时遇到的问题及解决方法

版权声明:本文为博主原创文章,未经博主允许不得用于任何商业用途,转载请注明出处。 https://blog.csdn.net/luoweifu/article/details/51476944

工具要求:

1.VS2013,更新至update4以上(这里用的是VS2013 Ultimate版Update5)(这个很重要,不然编译不了,因为skia用了很多C++11的新特性)
2.Python2.7.x
下载:https://www.python.org/downloads
3.google的最新depot_tools工具集:
下载:Google工具套件depot_tools 或自行到官网下载http://www.chromium.org/developers/how-tos/depottools
解决之后将depot_tools所在的路径加入到Path环境变量
4.skia版本:
commit 5d16fea9e22221be5fbe2866bbcfe8d6f4c6aeac
Author: joshualitt [email protected]
Date: Tue Dec 15 13:07:21 2015 -0800
Blacklist GLInstancedArraysBench on the ipad
BUG=skia:4714
Review URL: https://codereview.chromium.org/1529973002

Skia代码库:
https://skia.googlesource.com/skia(这个网址需自备云梯)
https://github.com/google/skia

生成VS工程解决方案:

SET “GYP_MSVS_VERSION=2013”
SET “GYP_GENERATORS=msvs”
python gyp_skia

编译时遇到的问题

说明:

https://skia.org/官方文件:https://skia.org/。Skia代码更新的非常快,文件的更新跟不上代码速度,所以文档的很多地方都更最新的项目对不上,以下我自己遇到的一些问题的总结。

遇到的问题一:

1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\sal_supp.h(57): error C2220: warning treated as error - no ‘object’ file generated (….\src\codec\SkAndroidCodec.cpp)
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\sal_supp.h(57): warning C4005: ‘__useHeader’ : macro redefinition (….\src\codec\SkAndroidCodec.cpp)
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\sal.h(2886) : see previous definition of ‘__useHeader’

解决方案:
方法1:更改Treat Warning As Errors为(No)的工程
右键工程->Properties->Configurations Properties->C/C++->General->Treat Warning As Errors,将它的值由Yes改为No。
(能编译通过但仍会有Warning)

方法2:将Platform Toolset设置为V120_xp
右键工程->Properties->Configurations Properties->General->Platform Toolset,它的值默认是Visual Studio 2013 (v120),将其设置为Visual Studio 2013 - Windows XP (v120_xp)

(能编译通过且没有警告)
方式(1).对出现错误的工程(如codec、codec_android、core、image、opts)设置为V120_xp
方式(2).对Solution下的所有工程都设置成V120_xp

遇到的问题二:

12>f:\cppworkspace\skia_ok\skia\src\effects\skdisplacementmapeffect.cpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

解决方案:
将错误指定的文件skdisplacementmapeffect.cpp保存成ANSI编码。用Windows自带的记事本打开skdisplacementmapeffect.cpp,另存为时指定保存的编码格式。

原理:

遇到的问题三:

1>gm.obj : warning LNK4075: ignoring ‘/EDITANDCONTINUE’ due to ‘/SAFESEH’ specification
解决方案:
Properties->Liner->Advanced->Image has Safe Exception Handler设置为No

遇到的问题四:

fatal error LINK127:fail during runing rc.exe

解决方案:
将C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin中的RC.Exe和RcDll.Dll拷到C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin中
将C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\x64中的RC.Exe和RcDll.Dll拷到C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86中

遇到的问题五:

编译时提示找不到yasm.exe

解决方案:
将yasm.exe拷贝到编译结果存放的目录,如Debug或Release目录(在本工程中是EpubKernel\Output\Win32\Debug\Bin和EpubKernel\Output\Win32\Release\Bin)。
yasm.exe在.\Skia\third_party\externals\yasm\binaries\win目录下。

VS2010项目升级到VS2013

由于skia要求在VS2013以上版本上编译,所以要将已有项目升级至VS2013。VS2010项目升级到VS2013项目时遇到的问题:

问题1:

1>f:\cppworkspace\epubkernel\thirdparty\zip\minizip\mztools.c(38): warning C4996: ‘fopen’: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

解决方案:
在Solution Explorer中右键点击出错的文件(或工程)Properties->Configurations->C/C++->Preprocessor中加入_CRT_SECURE_NO_WARNINGS宏

猜你喜欢

转载自blog.csdn.net/luoweifu/article/details/51476944