发布于 2017-06-02 11:53:12
如何解决问题:
添加库搜索路径
这个屏幕截图显示了如何和在何处执行以下步骤:
libskia.a库文件的路径。(注意:我使用静态构建选项来创建一个静态库。如果要链接动态.so库,则设置略有不同)静态链接与libskia.a
以下步骤应在与前面步骤相同的主窗口分区内执行。
-lskia以静态链接libskia.a库。确保设置了标头包含路径
以下步骤应在与前面步骤相同的主窗口分区内执行。
添加Mac特定的Skia依赖项
以下步骤应在与前面步骤相同的主窗口分区内执行。这个屏幕截图显示了在哪里执行这些步骤:
+标志。测试码
您可以使用以下示例代码测试这些设置:
#include "SkSurface.h"
#include "SkPath.h"
#include "SkCanvas.h"
#include "SkData.h"
#include "SkImage.h"
#include "SkStream.h"
int main (int argc, char * const argv[]) {
// hard coded example program parameters
const char filePath[] = "/Users/[yourUserName]/Desktop/skiaTestImage.png";
int width = 256;
int height = 256;
// create canvas to draw on
sk_sp<SkSurface> rasterSurface = SkSurface::MakeRasterN32Premul(width, height);
SkCanvas* canvas = rasterSurface->getCanvas();
// creating a path to be drawn
SkPath path;
path.moveTo(10.0f, 10.0f);
path.lineTo(100.0f, 0.0f);
path.lineTo(100.0f, 100.0f);
path.lineTo(0.0f, 100.0f);
path.lineTo(50.0f, 50.0f);
path.close();
// creating a paint to draw with
SkPaint p;
p.setAntiAlias(true);
// clear out which may be was drawn before and draw the path
canvas->clear(SK_ColorWHITE);
canvas->drawPath(path, p);
// make a PNG encoded image using the canvas
sk_sp<SkImage> img(rasterSurface->makeImageSnapshot());
if (!img) { return 1; }
sk_sp<SkData> png(img->encodeToData());
if (!png) { return 1; }
// write the data to the file specified by filePath
SkFILEWStream out(filePath);
(void)out.write(png->data(), png->size());
return 0;
}附录
用终端进行编译
您可以通过编写一个make文件或直接在终端中调用g++编译器来实现这一点。下面是一个示例:
g++ -std=c++11 main.cpp -framework CoreFoundation -framework \
CoreGraphics -framework CoreText -framework CoreServices - \
L[path_to_your_Skia_library]/skia/out/Static_m58 -lskia - \
I[path_to_your_Skia_library]/skia/include/core -\
I[path_to_your_Skia_library]/skia/include/config -\
I[path_to_your_Skia_library]/skia/include/utils -\
I[path_to_your_Skia_library]/skia/third_party/externals/sdl/include -\
I[path_to_your_Skia_library]/skia/include/gpu -\
I[path_to_your_Skia_library]/skia/src/gpu -o main我是如何找到解决方案的
发现这些东西花了我大约12个小时。如果您对最终导致解决方案的步骤感兴趣,我将在这里解释它们。告诉我就行了。
https://stackoverflow.com/questions/43841874
复制相似问题