diff --git a/Makefile b/Makefile index 6ee9bbe..1012ca0 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ # All examples will be built at a time. # EXAMPLE_DIRS := \ - examples/sdl3_opengl3 \ examples/imPlotDemo \ - examples/sdl2_opengl3 \ examples/glfw_opengl3 \ examples/glfw_opengl3_implot \ examples/glfw_opengl3_jp \ - examples/glfw_opengl3_image_load + examples/glfw_opengl3_image_load \ + examples/sdl2_opengl3 +ifeq ($(OS),Windows_NT) + EXAMPLE_DIRS += \ + examples/sdl3_opengl3 +endif all: $(foreach exdir,$(EXAMPLE_DIRS), $(call def_make,$(exdir),$@ )) diff --git a/README.md b/README.md index 040caaa..2c2a1ef 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ ImGui/CimGui version **1.91.3dock** (2024/10) --- - Windows10 OS or later +- Linux Mint 22 (Ubuntu/Debian families ?): Work in progress. - Now using zig-windows-x86_64-0.14.0-dev.1743 Probably [zig-windows-x86_64-0.14.0-dev.xxxx+yyyy...](https://ziglang.org/download/) might be ok. (-:) - MSys2/MinGW basic commands (make, rm, cp, strip ...) diff --git a/examples/glfw_opengl3/build.zig b/examples/glfw_opengl3/build.zig index bdbdfe2..0dbd403 100644 --- a/examples/glfw_opengl3/build.zig +++ b/examples/glfw_opengl3/build.zig @@ -64,10 +64,15 @@ pub fn build(b: *std.Build) void { // Define macro for C/C++ sources //-------------------------------- // ImGui - imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"); imlibs.defineCMacro("IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS", ""); imlibs.defineCMacro("ImDrawIdx", "unsigned int"); imlibs.defineCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS","1"); + switch (builtin.target.os.tag){ + .windows => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"), + .linux => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" "), + else => {}, + } + //--------------- // Sources C/C++ //--------------- @@ -129,16 +134,22 @@ pub fn build(b: *std.Build) void { //------ // Libs //------ - exe.linkSystemLibrary("gdi32"); - exe.linkSystemLibrary("imm32"); - exe.linkSystemLibrary("opengl32"); - exe.linkSystemLibrary("user32"); - exe.linkSystemLibrary("shell32"); + if (builtin.target.os.tag == .windows){ + exe.linkSystemLibrary("gdi32"); + exe.linkSystemLibrary("imm32"); + exe.linkSystemLibrary("opengl32"); + exe.linkSystemLibrary("user32"); + exe.linkSystemLibrary("shell32"); + // Static link + exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); + }else if (builtin.target.os.tag == .linux){ + exe.linkSystemLibrary("glfw3"); + exe.linkSystemLibrary("GL"); + } + // GLFW //exe.addLibraryPath(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-64"}))); //exe.linkSystemLibrary("glfw3"); // For static link - // Static link - exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); // Dynamic link //exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3dll.a"}))); //exe.linkSystemLibrary("glfw3dll"); // For dynamic link diff --git a/examples/glfw_opengl3_image_load/build.zig b/examples/glfw_opengl3_image_load/build.zig index c14a248..4e0646c 100644 --- a/examples/glfw_opengl3_image_load/build.zig +++ b/examples/glfw_opengl3_image_load/build.zig @@ -64,10 +64,15 @@ pub fn build(b: *std.Build) void { // Define macro for C/C++ sources //-------------------------------- // ImGui - imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"); imlibs.defineCMacro("IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS", ""); imlibs.defineCMacro("ImDrawIdx", "unsigned int"); imlibs.defineCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS","1"); + switch (builtin.target.os.tag){ + .windows => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"), + .linux => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" "), + else => {}, + } + //--------------- // Sources C/C++ //--------------- @@ -129,16 +134,22 @@ pub fn build(b: *std.Build) void { //------ // Libs //------ + if (builtin.target.os.tag == .windows){ exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("imm32"); exe.linkSystemLibrary("opengl32"); exe.linkSystemLibrary("user32"); exe.linkSystemLibrary("shell32"); + // Static link + exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); + }else if (builtin.target.os.tag == .linux){ + exe.linkSystemLibrary("glfw3"); + exe.linkSystemLibrary("GL"); + } + // GLFW //exe.addLibraryPath(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-64"}))); //exe.linkSystemLibrary("glfw3"); // For static link - // Static link - exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); // Dynamic link //exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3dll.a"}))); //exe.linkSystemLibrary("glfw3dll"); // For dynamic link diff --git a/examples/glfw_opengl3_implot/build.zig b/examples/glfw_opengl3_implot/build.zig index bc5c93a..775519a 100644 --- a/examples/glfw_opengl3_implot/build.zig +++ b/examples/glfw_opengl3_implot/build.zig @@ -67,10 +67,15 @@ pub fn build(b: *std.Build) void { // Define macro for C/C++ sources //-------------------------------- // ImGui - imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"); imlibs.defineCMacro("IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS", ""); imlibs.defineCMacro("ImDrawIdx", "unsigned int"); imlibs.defineCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS","1"); + switch (builtin.target.os.tag){ + .windows => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"), + .linux => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" "), + else => {}, + } + //--------------- // Sources C/C++ //--------------- @@ -139,16 +144,22 @@ pub fn build(b: *std.Build) void { //------ // Libs //------ + if (builtin.target.os.tag == .windows){ exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("imm32"); exe.linkSystemLibrary("opengl32"); exe.linkSystemLibrary("user32"); exe.linkSystemLibrary("shell32"); + // Static link + exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); + }else if (builtin.target.os.tag == .linux){ + exe.linkSystemLibrary("glfw3"); + exe.linkSystemLibrary("GL"); + } + // GLFW //exe.addLibraryPath(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-64"}))); //exe.linkSystemLibrary("glfw3"); // For static link - // Static link - exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); // Dynamic link //exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3dll.a"}))); //exe.linkSystemLibrary("glfw3dll"); // For dynamic link diff --git a/examples/glfw_opengl3_jp/build.zig b/examples/glfw_opengl3_jp/build.zig index 1ad479c..d000cba 100644 --- a/examples/glfw_opengl3_jp/build.zig +++ b/examples/glfw_opengl3_jp/build.zig @@ -64,10 +64,15 @@ pub fn build(b: *std.Build) void { // Define macro for C/C++ sources //-------------------------------- // ImGui - imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"); imlibs.defineCMacro("IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS", ""); imlibs.defineCMacro("ImDrawIdx", "unsigned int"); imlibs.defineCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS","1"); + switch (builtin.target.os.tag){ + .windows => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"), + .linux => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" "), + else => {}, + } + //--------------- // Sources C/C++ //--------------- @@ -129,16 +134,22 @@ pub fn build(b: *std.Build) void { //------ // Libs //------ + if (builtin.target.os.tag == .windows){ exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("imm32"); exe.linkSystemLibrary("opengl32"); exe.linkSystemLibrary("user32"); exe.linkSystemLibrary("shell32"); + // Static link + exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); + }else if (builtin.target.os.tag == .linux){ + exe.linkSystemLibrary("glfw3"); + exe.linkSystemLibrary("GL"); + } + // GLFW //exe.addLibraryPath(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-64"}))); //exe.linkSystemLibrary("glfw3"); // For static link - // Static link - exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); // Dynamic link //exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3dll.a"}))); //exe.linkSystemLibrary("glfw3dll"); // For dynamic link diff --git a/examples/imPlotDemo/build.zig b/examples/imPlotDemo/build.zig index 03253b6..c8fb96e 100644 --- a/examples/imPlotDemo/build.zig +++ b/examples/imPlotDemo/build.zig @@ -67,10 +67,15 @@ pub fn build(b: *std.Build) void { // Define macro for C/C++ sources //-------------------------------- // ImGui - imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"); imlibs.defineCMacro("IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS", ""); imlibs.defineCMacro("ImDrawIdx", "unsigned int"); imlibs.defineCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS","1"); + switch (builtin.target.os.tag){ + .windows => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"), + .linux => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" "), + else => {}, + } + //--------------- // Sources C/C++ //--------------- @@ -139,16 +144,22 @@ pub fn build(b: *std.Build) void { //------ // Libs //------ + if (builtin.target.os.tag == .windows){ exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("imm32"); exe.linkSystemLibrary("opengl32"); exe.linkSystemLibrary("user32"); exe.linkSystemLibrary("shell32"); + // Static link + exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); + }else if (builtin.target.os.tag == .linux){ + exe.linkSystemLibrary("glfw3"); + exe.linkSystemLibrary("GL"); + } + // GLFW //exe.addLibraryPath(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-64"}))); //exe.linkSystemLibrary("glfw3"); // For static link - // Static link - exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3.a"}))); // Dynamic link //exe.addObjectFile(b.path(b.pathJoin(&.{glfw_path, "lib-mingw-w64","libglfw3dll.a"}))); //exe.linkSystemLibrary("glfw3dll"); // For dynamic link diff --git a/examples/sdl2_opengl3/build.zig b/examples/sdl2_opengl3/build.zig index 347bf7e..94d07a7 100644 --- a/examples/sdl2_opengl3/build.zig +++ b/examples/sdl2_opengl3/build.zig @@ -1,3 +1,4 @@ +// Used zig-0.14.0-dev (2024/10) // Used zig-0.12.0 (2024/06) // const std = @import("std"); @@ -61,10 +62,15 @@ pub fn build(b: *std.Build) void { // Define macro for C/C++ sources //-------------------------------- // ImGui - imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"); imlibs.defineCMacro("IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS", ""); imlibs.defineCMacro("ImDrawIdx", "unsigned int"); imlibs.defineCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS","1"); + switch (builtin.target.os.tag){ + .windows => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"), + .linux => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" "), + else => {}, + } + //--------------- // Sources C/C++ //--------------- @@ -126,34 +132,41 @@ pub fn build(b: *std.Build) void { //------ // Libs //------ - exe.linkSystemLibrary("gdi32"); - exe.linkSystemLibrary("imm32"); - exe.linkSystemLibrary("advapi32"); - exe.linkSystemLibrary("comdlg32"); - exe.linkSystemLibrary("dinput8"); - exe.linkSystemLibrary("dxerr8"); - exe.linkSystemLibrary("dxguid"); - exe.linkSystemLibrary("gdi32"); - exe.linkSystemLibrary("hid"); - exe.linkSystemLibrary("kernel32"); - exe.linkSystemLibrary("ole32"); - exe.linkSystemLibrary("oleaut32"); - exe.linkSystemLibrary("setupapi"); - exe.linkSystemLibrary("shell32"); - exe.linkSystemLibrary("user32"); - exe.linkSystemLibrary("uuid"); - exe.linkSystemLibrary("version"); - exe.linkSystemLibrary("winmm"); - exe.linkSystemLibrary("winspool"); - exe.linkSystemLibrary("ws2_32"); - exe.linkSystemLibrary("opengl32"); - exe.linkSystemLibrary("shell32"); - exe.linkSystemLibrary("user32"); + if (builtin.target.os.tag == .windows){ + exe.linkSystemLibrary("gdi32"); + exe.linkSystemLibrary("imm32"); + exe.linkSystemLibrary("advapi32"); + exe.linkSystemLibrary("comdlg32"); + exe.linkSystemLibrary("dinput8"); + exe.linkSystemLibrary("dxerr8"); + exe.linkSystemLibrary("dxguid"); + exe.linkSystemLibrary("gdi32"); + exe.linkSystemLibrary("hid"); + exe.linkSystemLibrary("kernel32"); + exe.linkSystemLibrary("ole32"); + exe.linkSystemLibrary("oleaut32"); + exe.linkSystemLibrary("setupapi"); + exe.linkSystemLibrary("shell32"); + exe.linkSystemLibrary("user32"); + exe.linkSystemLibrary("uuid"); + exe.linkSystemLibrary("version"); + exe.linkSystemLibrary("winmm"); + exe.linkSystemLibrary("winspool"); + exe.linkSystemLibrary("ws2_32"); + exe.linkSystemLibrary("opengl32"); + exe.linkSystemLibrary("shell32"); + exe.linkSystemLibrary("user32"); + // Static link + exe.addObjectFile(b.path(b.pathJoin(&.{sdl2_path, "lib","libSDL2.a"}))); + }else if (builtin.target.os.tag == .linux){ + exe.linkSystemLibrary("glfw3"); + exe.linkSystemLibrary("GL"); + exe.linkSystemLibrary("SDL2"); + } + // sdl2 //exe.addLibraryPath(b.path(b.pathJoin(&.{sdl2_path, "lib-mingw-64"}))); //exe.linkSystemLibrary("SDL2"); // For static link - // Static link - exe.addObjectFile(b.path(b.pathJoin(&.{sdl2_path, "lib","libSDL2.a"}))); // Dynamic link //exe.addObjectFile(b.path(b.pathJoin(&.{sdl2_path, "lib","libSDL2dll.a"}))); //exe.linkSystemLibrary("SDL2dll"); // For dynamic link diff --git a/examples/sdl3_opengl3/build.zig b/examples/sdl3_opengl3/build.zig index eadc3d3..b11ad8f 100644 --- a/examples/sdl3_opengl3/build.zig +++ b/examples/sdl3_opengl3/build.zig @@ -59,10 +59,15 @@ pub fn build(b: *std.Build) void { // Define macro for C/C++ sources //-------------------------------- // ImGui - imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"); imlibs.defineCMacro("IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS", ""); imlibs.defineCMacro("ImDrawIdx", "unsigned int"); imlibs.defineCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS","1"); + switch (builtin.target.os.tag){ + .windows => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" __declspec(dllexport)"), + .linux => imlibs.defineCMacro("IMGUI_IMPL_API", "extern \"C\" "), + else => {}, + } + //--------------- // Sources C/C++ //--------------- @@ -124,34 +129,40 @@ pub fn build(b: *std.Build) void { //------ // Libs //------ - exe.linkSystemLibrary("gdi32"); - exe.linkSystemLibrary("imm32"); - exe.linkSystemLibrary("advapi32"); - exe.linkSystemLibrary("comdlg32"); - exe.linkSystemLibrary("dinput8"); - exe.linkSystemLibrary("dxerr8"); - exe.linkSystemLibrary("dxguid"); - exe.linkSystemLibrary("gdi32"); - exe.linkSystemLibrary("hid"); - exe.linkSystemLibrary("kernel32"); - exe.linkSystemLibrary("ole32"); - exe.linkSystemLibrary("oleaut32"); - exe.linkSystemLibrary("setupapi"); - exe.linkSystemLibrary("shell32"); - exe.linkSystemLibrary("user32"); - exe.linkSystemLibrary("uuid"); - exe.linkSystemLibrary("version"); - exe.linkSystemLibrary("winmm"); - exe.linkSystemLibrary("winspool"); - exe.linkSystemLibrary("ws2_32"); - exe.linkSystemLibrary("opengl32"); - exe.linkSystemLibrary("shell32"); - exe.linkSystemLibrary("user32"); + if (builtin.target.os.tag == .windows){ + exe.linkSystemLibrary("gdi32"); + exe.linkSystemLibrary("imm32"); + exe.linkSystemLibrary("advapi32"); + exe.linkSystemLibrary("comdlg32"); + exe.linkSystemLibrary("dinput8"); + exe.linkSystemLibrary("dxerr8"); + exe.linkSystemLibrary("dxguid"); + exe.linkSystemLibrary("gdi32"); + exe.linkSystemLibrary("hid"); + exe.linkSystemLibrary("kernel32"); + exe.linkSystemLibrary("ole32"); + exe.linkSystemLibrary("oleaut32"); + exe.linkSystemLibrary("setupapi"); + exe.linkSystemLibrary("shell32"); + exe.linkSystemLibrary("user32"); + exe.linkSystemLibrary("uuid"); + exe.linkSystemLibrary("version"); + exe.linkSystemLibrary("winmm"); + exe.linkSystemLibrary("winspool"); + exe.linkSystemLibrary("ws2_32"); + exe.linkSystemLibrary("opengl32"); + exe.linkSystemLibrary("shell32"); + exe.linkSystemLibrary("user32"); + // Static link + exe.addObjectFile(b.path(b.pathJoin(&.{sdlPath, "lib","libSDL3.a"}))); + }else if (builtin.target.os.tag == .linux){ + exe.linkSystemLibrary("glfw3"); + exe.linkSystemLibrary("GL"); + exe.linkSystemLibrary("SDL3"); + } // sdl3 //exe.addLibraryPath(b.path(b.pathJoin(&.{sdlPath, "lib-mingw-64"}))); //exe.linkSystemLibrary("SD32"); // For static link - // Static link - exe.addObjectFile(b.path(b.pathJoin(&.{sdlPath, "lib","libSDL3.a"}))); // Dynamic link //exe.addObjectFile(b.path(b.pathJoin(&.{sdlPath, "lib","libSDL3dll.a"}))); //exe.linkSystemLibrary("SDL3dll"); // For dynamic link