工具介绍
使用任何 Web 浏览器或 WebView 作为 GUI,后端使用您喜欢的语言,前端采用现代 Web 技术,所有内容都以轻量级可移植的形式提供。
## Download
- [Latest Stable Release](https://github.com/webui-dev/webui/releases)
- [Nightly Build](https://github.com/webui-dev/webui/releases/tag/nightly)
## Contents
- [Features](#features)
- [Showcase](#showcase)
- [UI & The Web Technologies](#ui--the-web-technologies)
- [Documentation](#documentation)
- [Build](#build)
- [Examples](#examples)
- [Wrappers](#wrappers)
- [Supported Web Browsers](#supported-web-browsers)
- [License](#license)
## Documentation
- [Online Documentation](https://webui.me/docs.html#/)
## Features
- Portable (*Only needs a web browser at runtime, WebView is optional*)
- Single header file
- Lightweight (*Few Kb library*) & Small memory footprint
- Fast binary WebSocket communication protocol
- Multi-platform & Multi-Browser
- Uses private profile for safety
- Cross-platform WebView (*Optional*)
## UI & The Web Technologies
[Borislav Stanimirov](https://ibob.bg/) discusses using HTML5 in the web browser as GUI at the [C++ Conference 2019 (_YouTube_)](https://www.youtube.com/watch?v=bbbcZd4cuxg).
Web application UI design is not just about how a product looks but how it works. Using web technologies in your UI makes your product modern and professional, And a well-designed web application will help you make a solid first impression on potential customers. Great web application design also assists you in nurturing leads and increasing conversions. In addition, it makes navigating and using your web app easier for your users.
### Why Use Web Browsers?
Today's web browsers have everything a modern UI needs. Web browsers are very sophisticated and optimized. Therefore, using it as a GUI will be an excellent choice. While old legacy GUI lib is complex and outdated, a WebView-based app is still an option. However, a WebView needs a huge SDK to build and many dependencies to run, and it can only provide some features like a real web browser. That is why WebUI uses real web browsers to give you full features of comprehensive web technologies while keeping your software lightweight and portable.
### How Does it Work?
Think of WebUI like a WebView controller, but instead of embedding the WebView controller in your program, which makes the final program big in size, and non-portable as it needs the WebView runtimes. Instead, by using WebUI, you use a tiny static/dynamic library to run any installed web browser and use it as GUI, which makes your program small, fast, and portable. **All it needs is a web browser**.
### Runtime Dependencies Comparison
| GUI | Windows Dependencies | Linux Dependencies | macOS Dependencies |
|-----------|---------|-------|-------|
| **Tauri** | WebView2 | GTK/WebKitGTK | WKWebView, WebKit |
| **Qt** | Qt bundles | Qt bundles, libxcb, libxkbcommon... | Qt bundles |
| **Electron** | Embedded Chromium + Node.js | Embedded Chromium + Node.js | Embedded Chromium + Node.js |
| **NW.js** | Embedded Chromium + Node.js | Embedded Chromium + Node.js | Embedded Chromium + Node.js |
| **WebUI** | **Only A Web Browser** | **Only A Web Browser** | **Only A Web Browser** |
## Build WebUI Library
### Windows
| Compiler | Command |
|----------|---------|
| GCC | `mingw32-make` |
| MSVC | `nmake` |
Windows SSL/TLS (Optional)
Download and install the OpenSSL pre-compiled binaries for Windows:
- **MSVC**: [x64 OpenSSL v3.3.1](https://slproweb.com/download/Win64OpenSSL-3_3_1.msi) or [_32Bit_](https://slproweb.com/download/Win32OpenSSL-3_3_1.msi). See the [Wiki list](https://wiki.openssl.org/index.php/Binaries) for more info.
- **MinGW**: [Curl for Windows with OpenSSL](https://curl.se/windows/)
```powershell
# GCC
mingw32-make WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="C:\curl-xxx-xxx-mingw\curl-xxx-xxx-mingw\include" WEBUI_TLS_LIB="C:\curl-xxx-xxx-mingw\curl-xxx-xxx-mingw\lib"
# MSVC
nmake WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="C:\Program Files\OpenSSL-xxx\include" WEBUI_TLS_LIB="C:\Program Files\OpenSSL-xxx\lib"
```
### Linux
| Compiler | Command |
|----------|---------|
| GCC | `make` |
| Clang | `make CC=clang` |
Linux SSL/TLS (Optional)
```sh
sudo apt update
sudo apt install libssl-dev
# GCC
make WEBUI_USE_TLS=1
# Clang
make WEBUI_USE_TLS=1 CC=clang
```
### macOS
| Compiler | Command |
|----------|---------|
| Default | `make` |
macOS SSL/TLS (Optional)
```sh
brew install openssl
make WEBUI_USE_TLS=1
```
## Minimal WebUI Application
- **C**
```c
#include "webui.h"
int main() {
size_t my_window = webui_new_window();
webui_show(my_window, " Hello World ! ");
webui_wait();
return 0;
}
```
- **C++**
```cpp
#include "webui.hpp"
#include
int main() {
webui::window my_window;
my_window.show(" C++ Hello World ! ");
webui::wait();
return 0;
}
```
- **More C/C++ Examples**
- [C](https://github.com/webui-dev/webui/tree/main/examples/C)
- [C++](https://github.com/webui-dev/webui/tree/main/examples/C++)
- **Other Languages**
- [Wrappers List](#Wrappers)
## Build WebUI Application
### Windows
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lws2_32 -Wall -luser32 -static -lole32 -lstdc++ -luuid -o my_application.exe` |
| GCC | Dynamic | `gcc -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" "webui-2.dll" -lws2_32 -Wall -luser32 -lole32 -o -lstdc++ -luuid my_application.exe` |
| MSVC | Static | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
| MSVC | Dynamic | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
Windows With SSL/TLS (Optional)
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lws2_32 -Wall -luser32 -static -lole32 -lstdc++ -luuid -o my_application.exe` |
| GCC | Dynamic | `gcc -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" "webui-2-secure.dll" -lws2_32 -Wall -luser32 -lole32 -lstdc++ -luuid -o my_application.exe` |
| MSVC | Static | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2-secure-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
| MSVC | Dynamic | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2-secure.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
### Linux
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lpthread -lm -ldl -o my_application` |
| GCC | Dynamic | `gcc my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2 -lpthread -lm -ldl -o my_application` |
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lpthread -lm -ldl -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2 -lpthread -lm -ldl -o my_application` |
Linux With SSL/TLS (Optional)
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lpthread -lm -ldl -o my_application` |
| GCC | Dynamic | `gcc my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure -lpthread -lm -ldl -o my_application` |
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lpthread -lm -ldl -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure -lpthread -lm -ldl -o my_application` |
### macOS
| Compiler | Type | Command |
|----------|--------|---------|
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2 -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
macOS With SSL/TLS (Optional)
| Compiler | Type | Command |
|----------|--------|---------|
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
## Wrappers
| Language | v2.5.0 API | Link |
| --------------- | ---------- | ---------------------------------------------------- |
| Python | ✔️ | [Python-WebUI](https://github.com/webui-dev/python-webui) |
| Go | ✔️ | [Go-WebUI](https://github.com/webui-dev/go-webui) |
| Zig | ✔️ | [Zig-WebUI](https://github.com/webui-dev/zig-webui) |
| Nim | ✔️ | [Nim-WebUI](https://github.com/webui-dev/nim-webui) |
| V | ✔️ | [V-WebUI](https://github.com/webui-dev/v-webui) |
| Rust | ✔️ | [Rust-WebUI](https://github.com/webui-dev/rust-webui) |
| TS / JS (Deno) | ✔️ | [Deno-WebUI](https://github.com/webui-dev/deno-webui) |
| TS / JS (Bun) | ✔️ | [Bun-WebUI](https://github.com/webui-dev/bun-webui) |
| Swift | ✔️ | [Swift-WebUI](https://github.com/webui-dev/swift-webui) |
| Odin | ✔️ | [Odin-WebUI](https://github.com/webui-dev/odin-webui) |
| Pascal | ✔️ | [Pascal-WebUI](https://github.com/webui-dev/pascal-webui) |
| Purebasic | ✔️ | [Purebasic-WebUI](https://github.com/webui-dev/purebasic-webui) |
| - | - | - |
| C# | ✔️ | [CS-WebUI](https://github.com/Runic-Artifex/cs-webui) |
| C# | _not complete_ | [WebUI4CSharp](https://github.com/salvadordf/WebUI4CSharp) |
| FSharp-WebUI | ✔️ | [FSharp-WebUI](https://github.com/no-waves/FSharp-WebUI) |
| Common Lisp | _not complete_ | [cl-webui](https://github.com/garlic0x1/cl-webui) |
| Delphi | _not complete_ | [WebUI4Delphi](https://github.com/salvadordf/WebUI4Delphi) |
| WebUI.NET | _not complete_ | [WebUI.NET](https://github.com/Juff-Ma/WebUI.NET) |
| QuickJS | _not complete_ | [QuickUI](https://github.com/xland/QuickUI) |
| PHP | _not complete_ | [PHPWebUiComposer](https://github.com/KingBes/php-webui-composer) |
## Supported Web Browsers
| Browser | Windows | macOS | Linux |
| --------------- | --------------- | ------------- | --------------- |
| Mozilla Firefox | ✔️ | ✔️ | ✔️ |
| Google Chrome | ✔️ | ✔