You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Currently, imgui links with shared library libstdc++ and libgcc, causing the executable to not be portable (useful in making installers or portable apps). There should be an option to static-link stdc++ with the libcimgui.a.
To Reproduce
Compile executable with imgui-rs and statically-compiled SDL2
Try to run it outside development environment
"Cannot find libstdc++-6.dll"
Expected behavior
Application runs without any external dependencies
Please describe your environment
imgui-rs main
Microsoft Windows (MSYS2 MinGW UCRT64)
Other information
Working fix (needs customization, wip)
diff --git a/imgui-sdl2-support/Cargo.toml b/imgui-sdl2-support/Cargo.toml
index 5935df8..08a4301 100644
--- a/imgui-sdl2-support/Cargo.toml
+++ b/imgui-sdl2-support/Cargo.toml
@@ -12,7 +12,7 @@ categories = ["gui"]
[dependencies]
imgui = { version = "0.11.0", path = "../imgui" }
-sdl2 = "0.36.0"
+sdl2 = { version = "0.36.0", features = ["bundled", "static-link"] }
[dev-dependencies]
glow = "0.12.0"
diff --git a/imgui-sys/build.rs b/imgui-sys/build.rs
index 0951589..ffb9d7f 100644
--- a/imgui-sys/build.rs
+++ b/imgui-sys/build.rs
@@ -58,10 +58,10 @@ fn main() -> std::io::Result<()> {
if !wasm_enabled {
// C++ compiler
let mut build = cc::Build::new();
- build.cpp(true);
+ build.cpp(false);
// imgui uses C++11 stuff from v1.87 onwards
- build.flag_if_supported("-std=c++11");
+ build.flag("-std=gnu++11");
// Set defines for compiler
for (key, value) in DEFINES.iter() {
@@ -104,11 +104,11 @@ fn main() -> std::io::Result<()> {
// Avoid the if-supported flag functions for easy cases, as they're
// kinda costly.
if compiler.is_like_gnu() || compiler.is_like_clang() {
- build.flag("-fno-exceptions").flag("-fno-rtti");
+ build.flag("-fno-exceptions").flag("-fno-rtti").flag("-fno-threadsafe-statics");
}
// Build imgui lib, suppressing warnings.
- build.warnings(false).file(imgui_cpp).compile("libcimgui.a");
+ build.warnings(false).file(imgui_cpp).static_flag(true).shared_flag(false).compile("libcimgui.a");
}
Ok(())
}
The text was updated successfully, but these errors were encountered:
Describe the bug
Currently, imgui links with shared library libstdc++ and libgcc, causing the executable to not be portable (useful in making installers or portable apps). There should be an option to static-link stdc++ with the libcimgui.a.
To Reproduce
Expected behavior
Application runs without any external dependencies
Please describe your environment
Other information
Working fix (needs customization, wip)
The text was updated successfully, but these errors were encountered: