Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.
TypeScript ai-photo-editorcomfyui-alternativegenerative-fillimage-editingimage-generationinpaintinglinuxlocal-aimacosmcpmcp-servernano-banana-alternativeofflinephoto-editorprivacyqwen-imageqwen-image-2-1stable-diffusion-cppvulkanwindows
Linux build: link GCC 13's libstdc++ statically into kokon-service for ONNX Runtime
Gabriele Lozupone8723ae9949ea
diff --git a/crates/qls-core/build.rs b/crates/qls-core/build.rsindex b8e6592..a81bec8 100644--- a/crates/qls-core/build.rs+++ b/crates/qls-core/build.rs@@ -1,18 +1,48 @@-// macOS: ONNX Runtime's CoreML code (in the static runtime `ort` downloads for the Mac) calls-// `___isPlatformVersionAtLeast` (Objective-C `@available`), which lives in clang's runtime library.-// The release build (thin LTO) did not get it and every binary with qls-core failed to link-// (0.12.0, 2026-11-04; dev builds linked). Linking libclang_rt.osx.a from the toolchain fixes it.+// Linking the ONNX Runtime that `ort` downloads (AI watermark, fast stickers) into release builds.+//+// macOS: its CoreML code calls `___isPlatformVersionAtLeast` (Objective-C `@available`), which lives in+// clang's runtime library. The release build (thin LTO) did not get it and every binary with qls-core+// failed to link (0.12.0, 2026-11-04; dev builds linked). Linking libclang_rt.osx.a fixes it.+//+// Linux: it is built with GCC 13 and needs its libstdc++ (GLIBCXX_3.4.32); Ubuntu 22.04, which the+// .deb, .rpm and Docker image are built on so they run on glibc 2.35, has GCC 11's. With g++-13+// installed (ubuntu-toolchain-r PPA; docs/linux.md), its libstdc++.a is put in a folder of its own+// and found before the system's .so: the service carries the newer libstdc++ statically and users+// need nothing new. Without g++-13 the system's is used (enough on Ubuntu 24.04 and newer).+use std::path::Path;+use std::process::Command;+fn main() {println!("cargo:rerun-if-changed=build.rs");- if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("macos") {- return;+ match std::env::var("CARGO_CFG_TARGET_OS").as_deref() {+ Ok("macos") => clang_runtime(),+ Ok("linux") => static_libstdcxx(),+ _ => {}}- let Ok(out) = std::process::Command::new("clang").arg("--print-runtime-dir").output() else { return };+}++fn clang_runtime() {+ let Ok(out) = Command::new("clang").arg("--print-runtime-dir").output() else { return };let dir = String::from_utf8_lossy(&out.stdout).trim().to_string();- if std::path::Path::new(&dir).join("libclang_rt.osx.a").is_file() {+ if Path::new(&dir).join("libclang_rt.osx.a").is_file() {println!("cargo:rustc-link-search=native={dir}");println!("cargo:rustc-link-lib=static=clang_rt.osx");} else {println!("cargo:warning=libclang_rt.osx.a not found in {dir}: a release build may fail to link ONNX Runtime");}}++fn static_libstdcxx() {+ for v in (13..=20).rev() {+ let Ok(out) = Command::new(format!("g++-{v}")).arg("-print-file-name=libstdc++.a").output() else { continue };+ let lib = String::from_utf8_lossy(&out.stdout).trim().to_string();+ if !out.status.success() || !Path::new(&lib).is_absolute() || !Path::new(&lib).is_file() {+ continue;+ }+ let dir = Path::new(&std::env::var("OUT_DIR").unwrap()).join("static-libstdcxx");+ std::fs::create_dir_all(&dir).unwrap();+ std::fs::copy(&lib, dir.join("libstdc++.a")).unwrap();+ println!("cargo:rustc-link-search=native={}", dir.display());+ return;+ }+}diff --git a/docker/Dockerfile b/docker/Dockerfileindex 6b58a81..77d0104 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -9,8 +9,12 @@FROM ubuntu:22.04 AS buildARG DEBIAN_FRONTEND=noninteractive+# g++-13: ONNX Runtime (AI watermark, stickers) needs GCC 13's libstdc++, linked into kokon-service+# statically (crates/qls-core/build.rs), so the runtime image below needs nothing new.RUN apt-get update \- && apt-get install -y --no-install-recommends build-essential ca-certificates curl pkg-config libssl-dev \+ && apt-get install -y --no-install-recommends build-essential ca-certificates curl pkg-config libssl-dev software-properties-common gpg-agent \+ && add-apt-repository -y ppa:ubuntu-toolchain-r/test \+ && apt-get install -y --no-install-recommends g++-13 \&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \&& apt-get install -y --no-install-recommends nodejs \&& rm -rf /var/lib/apt/lists/*diff --git a/docs/linux.md b/docs/linux.mdindex 490b441..ac9cb8a 100644--- a/docs/linux.md+++ b/docs/linux.md@@ -83,6 +83,10 @@ Upstream moves fast. Every platform follows the same release, so:→ `dist-release/Kokon_<v>_amd64.deb`, `Kokon-<v>-1.x86_64.rpm`, `updater-linux-x86_64-{deb,rpm}.json`.Signed with the same updater key as Windows/Mac (`~/.tauri/kokon-updater.key`, also found under/mnt/c/Users/*/.tauri).+- **g++-13** (ubuntu-toolchain-r PPA, `--setup` installs it; since 0.12): the ONNX Runtime that `ort`+ downloads (AI watermark, fast stickers) needs GCC 13's libstdc++ and Ubuntu 22.04 has GCC 11's.+ `crates/qls-core/build.rs` links g++-13's `libstdc++.a` into kokon-service statically, so users need+ nothing new. The Docker image's build stage installs it too.- Quick run without packaging: `npm run build && cargo build -p kokon --release --featurestauri/custom-protocol && ./target/release/kokon` (without the feature the window loads the dev serverand shows "Could not connect to localhost").diff --git a/scripts/build-release-linux.sh b/scripts/build-release-linux.shindex 44ab2f4..36b5956 100644--- a/scripts/build-release-linux.sh+++ b/scripts/build-release-linux.sh@@ -20,6 +20,13 @@ if [ "${1:-}" = "--setup" ]; thensudo apt-get updatesudo apt-get install -y build-essential curl wget file pkg-config libssl-dev libgtk-3-dev \libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev libxdo-dev patchelf+ # g++-13: ONNX Runtime (AI watermark, stickers) needs GCC 13's libstdc++, linked into kokon-service+ # statically (crates/qls-core/build.rs); Ubuntu 22.04 has GCC 11.+ if ! command -v g++-13 >/dev/null; then+ sudo apt-get install -y software-properties-common+ sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test+ sudo apt-get install -y g++-13+ fi# Not Ubuntu's cargo package (too old for this workspace): rustup's current stable.command -v rustup >/dev/null || [ -x "$HOME/.cargo/bin/rustup" ] || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -yif ! node --version 2>/dev/null | grep -q '^v2[2-9]'; then@@ -34,6 +41,7 @@ ficargo --version | grep -qE "^cargo 1.(8[4-9]|9[0-9]|[1-9][0-9]{2})" || { echo "✗ $(cargo --version) is too old (Ubuntu's package?): sudo apt remove cargo rustc, then run with --setup."; exit 1; }for c in cargo node npm pkg-config; do command -v "$c" >/dev/null || { echo "✗ $c not found: run with --setup first."; exit 1; }; donepkg-config --exists webkit2gtk-4.1 || { echo "✗ webkit2gtk-4.1 not found: run with --setup first."; exit 1; }+command -v g++-13 >/dev/null || { echo "✗ g++-13 not found (ONNX Runtime needs its libstdc++): run with --setup first."; exit 1; }echo "1/5 Packages"npm ci --no-audit --no-fund