A guide for developers who want to use BlinkGTK as the rendering
engine in another project — a custom
application, a 3D viewer, an EPUB reader, and so on.
Audience: developers who link against BlinkGTK through its C
API / pkg-config without modifying
BlinkGTK's own sources.
There are two ways to use BlinkGTK from the outside.
| Approach | Audience | Advantages | Drawbacks |
|---|---|---|---|
| A. Binary package | General developers, distribution | No Chromium sources needed; pkg-config works | Fixed install location |
| B. Directly from a Chromium build tree | BlinkGTK developers, tracking the latest features | Try the newest BlinkGTK immediately | Requires a full Chromium build |
Recommendation: start with approach A, and move to
approach B once you need deeper integration or |
the newest features.
# Fedora / RHEL (RPM)
sudo dnf install ./blinkgtk-bin-1.0.8-1.fc43.x86_64.rpm
# Debian / Ubuntu (DEB)
sudo dpkg -i ./libblinkgtk-0.1-0_1.0.8-1_amd64.deb \
./libblinkgtk-0.1-dev_1.0.8-1_amd64.deb
# Generic tarball
tar xjf blinkgtk-1.2.2-build6-linux-x86_64.tar.bz2
cd blinkgtk-1.2.2-build6-linux-x86_64
sudo ./install.sh # defaults to /usr/localpkg-config --cflags blinkgtk-0.1
# → -I/usr/include/blinkgtk-0.1 -I/usr/include/gtk-4.0 ...
pkg-config --libs blinkgtk-0.1
# → -lblinkgtk -lgtk-4 -lglib-2.0 ...// myapp.c
#include <blink_gtk/blink_gtk.h>
#include <gtk/gtk.h>
static void on_activate(GtkApplication* app, gpointer user_data) {
GtkWidget* win = gtk_application_window_new(app);
gtk_window_set_default_size(GTK_WINDOW(win), 1024, 768);
GtkWidget* view = blink_web_view_new();
gtk_window_set_child(GTK_WINDOW(win), view);
blink_web_view_load_uri(BLINK_WEB_VIEW(view),
"https://example.com");
gtk_window_present(GTK_WINDOW(win));
}
int main(int argc, char** argv) {
blink_gtk_init(&argc, &argv); /* GTK4 は引数なし */
GtkApplication* app = gtk_application_new(
"com.example.myapp", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, "activate", G_CALLBACK(on_activate), NULL);
/* BlinkGTK needs Chromium's browser main loop to run.
* g_application_run() does not run it, so the page never loads
* (the navigation never commits). Use register -> activate ->
* blink_gtk_run_main_loop() instead.
*/
GError *error = NULL;
if (!g_application_register(G_APPLICATION(app), NULL, &error)) {
g_printerr("Failed to register the application: %s\n", error ? error->message : "unknown error");
g_clear_error(&error);
g_object_unref(app);
return 1;
}
g_application_activate(G_APPLICATION(app));
int rc = blink_gtk_run_main_loop();
g_object_unref(app);
blink_gtk_shutdown();
return rc;
}Include only
blink_gtk.h. Up to v1.2.0-build5 the package also shipped
blink_web_view.h, an internal header left over from before the GObject migration.
Including both producesconflicting types for 'BlinkWebView'and fails to compile,
so it is no longer shipped.
cc myapp.c -o myapp $(pkg-config --cflags --libs blinkgtk-0.1 gtk4)# Run from the bin directory of the package installation
/usr/local/blinkgtk-1.0.8/bin/run-with-resources ./myappImportant: BlinkGTK loads Chromium resource files (ICU data, the V8 snapshot, locales) from the
directory next to the binary. Either use therun-with-resourcesscript shipped with the package, or
see "Placing resource files" below.
For developers who place BlinkGTK at
third_party/blinkgtk in a Chromium tree and build it
there.
cd /path/to/chromium/src
git clone https://blinkgtk.org/ third_party/blinkgtk
# assumes is_component_build=true is already set in your gn args
autoninja -C out/Release_Component \
third_party/blinkgtk/examples:simple_browser \
libblink_core.so libblink_platform.so libblink_modules.so libv8.so \
content_shell.pak v8_context_snapshot.bin \
locales/ja.pak locales/en-US.pakcd /path/to/chromium/src/out/Release_Component
LD_LIBRARY_PATH=$PWD \
BLINKGTK_GPU_MODE=swiftshader \
./myapp --no-sandbox --no-zygoteAlways run from inside the
out/Release_Componentdirectory. At startup BlinkGTK looks for
./icudtl.dat,./v8_context_snapshot.bin,./content_shell.pak, and./locales/.
When running an external application outside a Chromium build tree,
the following files must sit in the
same directory as the executable.
| File | Purpose | Symptom if missing |
|---|---|---|
icudtl.dat |
ICU internationalization data | FATAL: Couldn't mmap icu data file |
content_shell.pak |
UI resources | FATAL: LoadFromPath failed |
v8_context_snapshot.bin |
Faster V8 startup | FATAL: Error loading V8 startup snapshot |
snapshot_blob.bin |
V8 initial heap | SIGTRAP on a V8 version
mismatch |
locales/ directory |
UI localization (ja.pak,
en-US.pak, …) |
Starts, but translations are missing |
SwiftShader mode
(BLINKGTK_GPU_MODE=swiftshader):
| File | Purpose |
|---|---|
libEGL.so |
ANGLE EGL implementation |
libGLESv2.so |
ANGLE GLES2 implementation |
libvk_swiftshader.so |
SwiftShader Vulkan |
vk_swiftshader_icd.json |
Vulkan ICD manifest |
Native EGL mode
(BLINKGTK_GPU_MODE=egl):
No additional files are needed because the system EGL / GL libraries
are used. The system does need a
Wayland-capable EGL driver (Mesa, NVIDIA, and so on).
# Planned: extract the required files from a Chromium build
scripts/setup-dev-env.sh \
--chromium-src=/path/to/chromium/src \
--target-dir=/path/to/your/app/runtimeSwitch with the BLINKGTK_GPU_MODE environment variable.
The default is software.
| Mode | On-screen rendering | Intended use |
|---|---|---|
software |
Yes | Headless, servers, CI, low-spec environments |
swiftshader |
Yes | Virtual machines, machines without a GPU, stability first |
egl |
Supported | Desktop, machines with a GPU. White screen on v1.2.0-build2 and earlier (fixed in the next release) |
See GPU modes for details.
Likely causes:
.pak, .bin) were not
found, so Blink never initializedGtkOverlay, so frame pixels
are not displayedblink_web_view_load_uri() was called before
gtk_widget_realize()How to check:
# Look for the line where blink_gtk_init completed, and the line that hands pixels to the screen
./myapp 2>&1 | grep -E "blink_gtk_init|FATAL|set_dmabuf_pixels"blink_gtk_init → resources are
missingset_dmabuf_pixels → the rendering
pipeline never startedset_dmabuf_pixels appears but every pixel is white →
the loaded HTML may simply have an emptyThe resource files are not next to the executable. Either copy
icudtl.dat there, or point at it
explicitly with blink_gtk_set_icu_data_path().
blink_gtk_set_icu_data_path("/opt/myapp/icudtl.dat");
blink_gtk_init(&argc, &argv); /* GTK4 は引数なし */ // must be called before initbuild/libblinkgtk.so segfaults"build/ at the repository root is mock output
from the old Meson build. Meson was removed in
v1.0.1, but the directory may still be present on disk.
rm -rf build/When linking from an external application, always reference either
the installed
/usr/lib64/libblinkgtk.so or
out/Release_Component/libblinkgtk.so inside the Chromium
build tree.
blinkgtk-0.1"export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
pkg-config --list-all | grep blinkgtkFor a tarball installation, add the installation's
lib/pkgconfig to PKG_CONFIG_PATH.
pkg-config --modversion blinkgtk-0.1)ldd libblinkgtk.so | grep libcontent)BLINKGTK_GPU_MODE)./myapp 2>&1 | head -50)