Issue with Skia static lib

20 views
Skip to first unread message

kvs...@gmail.com

unread,
Jun 3, 2021, 6:21:20 AM (10 days ago) Jun 3
to skia-discuss
1. build skia as static library. https://skia.org/docs/user/build/
2. create main.cpp
3. run command[1] below failed
```
clang -std=c++14 -stdlib=libc++ -I../skia -I../skia/include -I../skia/include/core -I../skia/include/ports -I../skia/include/config -I../skia/include/gpu -lstdc++ -L../skia/out/Static -lskia -Wl,-rpath,../skia/out/Static main.cpp -g -O1 -o main
```

error message is :
```
In file included from main.cpp:1:
In file included from ../skia/include/core/SkSurface.h:11:
In file included from ../skia/include/core/SkImage.h:12:
In file included from ../skia/include/core/SkImageEncoder.h:11:
In file included from ../skia/include/core/SkBitmap.h:11:
In file included from ../skia/include/core/SkColor.h:11:
In file included from ../skia/include/core/SkImageInfo.h:11:
In file included from ../skia/include/core/SkColorSpace.h:11:
../skia/include/core/SkRefCnt.h:13:10: fatal error: 'atomic' file not found
#include <atomic>       // std::atomic, std::memory_order_*
         ^~~~~~~~
1 error generated.
```



env:
cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster

gcc --version
gcc (Debian 8.3.0-6) 8.3.0

clang --version
clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
Target: x86_64-pc-linux-gnu

main.cpp
```
#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[]) {

const char filePath[] = "a.png";
int width = 256;
int height = 256;


sk_sp<SkSurface> rasterSurface = SkSurface::MakeRasterN32Premul(width, height);
SkCanvas* canvas = rasterSurface->getCanvas();


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();


SkPaint p;
p.setAntiAlias(true);


canvas->clear(SK_ColorWHITE);
canvas->drawPath(path, p);


sk_sp<SkImage> img(rasterSurface->makeImageSnapshot());
if (!img) { return 1; }
sk_sp<SkData> png(img->encodeToData());
if (!png) { return 1; }


SkFILEWStream out(filePath);
(void)out.write(png->data(), png->size());

return 0;
}
```



kvs...@gmail.com

unread,
Jun 3, 2021, 11:18:58 PM (9 days ago) Jun 3
to skia-discuss
```
clang main.cpp -std=c++17 -lGL -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib -pthread -lSDL2 -I. -L../skia/out/Static -lskia -I../skia -I../skia/include -I../skia/include/core -I../skia/include/ports -I../skia/include/config -I../skia/include/gpu -lfontconfig -lfreetype -lfreetype -lstdc++ -ldl -lm -pthread -Wall -Wextra -DGR_GL_LOG_CALLS=0 -DGR_GL_CHECK_ERROR=0 -o main
```
Reply all
Reply to author
Forward
0 new messages