Skip to content

Commit

Permalink
Compilation possibility on Linux OS
Browse files Browse the repository at this point in the history
  • Loading branch information
dinau committed Oct 10, 2024
1 parent 3710dce commit 41aa66f
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 75 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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),$@ ))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...)
Expand Down
27 changes: 19 additions & 8 deletions examples/glfw_opengl3/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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++
//---------------
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions examples/glfw_opengl3_image_load/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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++
//---------------
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions examples/glfw_opengl3_implot/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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++
//---------------
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions examples/glfw_opengl3_jp/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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++
//---------------
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions examples/imPlotDemo/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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++
//---------------
Expand Down Expand Up @@ -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
Expand Down
65 changes: 39 additions & 26 deletions examples/sdl2_opengl3/build.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Used zig-0.14.0-dev (2024/10)
// Used zig-0.12.0 (2024/06)
//
const std = @import("std");
Expand Down Expand Up @@ -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++
//---------------
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 41aa66f

Please sign in to comment.