GrDirectContext::MakeGL functions undefined

507 views
Skip to first unread message

Alex Humphrey

unread,
Aug 7, 2023, 10:29:45 AM8/7/23
to skia-discuss
I'm attempting to compile a project that uses SDL2 & Skia on Ubuntu.

I am able to build Skia through gn with the following:
```
bin/gn gen out/shared --args='is_component_build=true is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_system_icu=false skia_use_system_harfbuzz=false'
```

I have also attempted building skia with the following args added and achieved the same result:
```
--defines=["SK_GL"]
skia_use_gl=true
skia_enable_gpu=true

// I have also added '#define SK_GL' to the top of main.cpp
```

Skia appears to sucessfully build, however when I come to build my own project and link against the libs gn produced, I am told by the linker that the MakeGL functions in GrDirectContext are undefined. I am attempting to build using the following:
```
eval "g++ main.cpp -o out  -I ../skia -I ../skia/include -L ../skia/out/shared -lglut -lGLU -lGL -lSDL2"
```

The linker produces:
```
main.cpp: In function ‘int main(int, char**)’:
main.cpp:79:58: error: ‘MakeGL’ is not a member of ‘GrDirectContext’
                                         sk_sp<GrDirectContext> gr_context = GrDirectContext::MakeGL(interface);
```

The error appears whether I'm building on Ubuntu or through WSL. I am assuming there's an OpenGL flag missing somewhere as the function defs I'm missing are wrapped in an ifdef that looks for 'SK_GL', however even placing '#define SK_GL' at the top of my main.cpp before the includes is doing nothing, so I'm at a bit of a loss.

I'm new to working with UNIX systems so if I'm missing something very obvious I apologise in advance.

Any help greatly appreciated.

William Candillon

unread,
Aug 7, 2023, 3:54:41 PM8/7/23
to skia-discuss
We've had a similar issue in the past, and I think we were missing the SK_GANESH flag (https://groups.google.com/g/skia-discuss/c/2hA_8Fcfih4/m/crPPJfiQAQAJ).
These are our preprocessor options for OpenGL.
-DSK_GL -DSK_GANESH

Kind regards,

William

Alex Humphrey

unread,
Aug 9, 2023, 8:56:42 AM8/9/23
to skia-discuss
Could you specify exactly how you are passing these to gn? I tried adding them as defines and as c flags however neither changes anything, but I've likely got the syntax slightly wrong. Running gn args out/shared --list also shows that skia_enable_ganesh, skia_enable_gpu & skia_use_gl are all set to true.

William Candillon

unread,
Aug 9, 2023, 9:22:10 AM8/9/23
to skia-d...@googlegroups.com
This is after the gn step. When you include the Skia header files in
your code, you need the right preprocessor directives.

Kind regards,

William
> --
> You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/O4iBSohokrg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/5ab58544-1bb0-4323-8944-efbdcc6f8dfbn%40googlegroups.com.

Alex Humphrey

unread,
Aug 10, 2023, 8:53:52 AM8/10/23
to skia-discuss
This was indeed the issue. Thanks William, your help is greatly appreciated!
Reply all
Reply to author
Forward
0 new messages