diff --git a/engines/release/dynamics_c.dll b/engines/release/dynamics_c.dll index f10c8b6..289b05d 100644 Binary files a/engines/release/dynamics_c.dll and b/engines/release/dynamics_c.dll differ diff --git a/engines/release/dynamics_cpp.dll b/engines/release/dynamics_cpp.dll index dfa7ce3..1b83aff 100644 Binary files a/engines/release/dynamics_cpp.dll and b/engines/release/dynamics_cpp.dll differ diff --git a/engines/release/dynamics_f90.dll b/engines/release/dynamics_f90.dll index c72fd9f..b8cd986 100644 Binary files a/engines/release/dynamics_f90.dll and b/engines/release/dynamics_f90.dll differ diff --git a/engines/src/c/Makefile b/engines/src/c/Makefile index 97e84bd..6eb7418 100644 --- a/engines/src/c/Makefile +++ b/engines/src/c/Makefile @@ -9,6 +9,16 @@ LIB_SRC = dynamics_lib.c # 自动检测系统 UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) +# Windows 检测:Msys2/MINGW 也视为 Windows +IS_WINDOWS := $(findstring MINGW,$(UNAME_S)) +ifneq ($(IS_WINDOWS),) + UNAME_S := Windows +endif +IS_WINDOWS := $(findstring MSYS,$(UNAME_S)) +ifneq ($(IS_WINDOWS),) + UNAME_S := Windows +endif + # DLL 输出到 engines/release/ DLL_DIR = ../../release @@ -19,8 +29,9 @@ else ifeq ($(UNAME_S),Darwin) DLL_TARGET = $(DLL_DIR)/dynamics_c.dylib DLL_FLAGS = -dynamiclib else + # Windows: 静态链接运行时,避免依赖 libgcc_s_seh-1.dll DLL_TARGET = $(DLL_DIR)/dynamics_c.dll - DLL_FLAGS = -shared + DLL_FLAGS = -shared -static endif .PHONY: all dll clean diff --git a/engines/src/cpp/Makefile b/engines/src/cpp/Makefile index 08e071f..7a4ec66 100644 --- a/engines/src/cpp/Makefile +++ b/engines/src/cpp/Makefile @@ -6,14 +6,17 @@ LIB_SRC = dynamics_lib.cpp UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) -CXXFLAGS = -O3 -march=native -std=c++17 -Wall -Wextra -D_USE_MATH_DEFINES - -# Windows 下静态链接运行时 -ifeq ($(UNAME_S),Windows) - STATIC_FLAGS = -static-libgcc -static-libstdc++ -else - STATIC_FLAGS = +# Windows 检测:Msys2/MINGW 也视为 Windows +IS_WINDOWS := $(findstring MINGW,$(UNAME_S)) +ifneq ($(IS_WINDOWS),) + UNAME_S := Windows endif +IS_WINDOWS := $(findstring MSYS,$(UNAME_S)) +ifneq ($(IS_WINDOWS),) + UNAME_S := Windows +endif + +CXXFLAGS = -O3 -march=native -std=c++17 -Wall -Wextra -D_USE_MATH_DEFINES # DLL 输出到 engines/release/ DLL_DIR = ../../release @@ -25,8 +28,9 @@ else ifeq ($(UNAME_S),Darwin) DLL_TARGET = $(DLL_DIR)/dynamics_cpp.dylib DLL_FLAGS = -dynamiclib else + # Windows: 完全静态链接,避免依赖运行时 DLL DLL_TARGET = $(DLL_DIR)/dynamics_cpp.dll - DLL_FLAGS = -shared + DLL_FLAGS = -shared -static endif .PHONY: all dll clean @@ -36,7 +40,7 @@ all: dll dll: $(DLL_TARGET) $(DLL_TARGET): $(LIB_SRC) | $(DLL_DIR) - $(CXX) $(CXXFLAGS) $(STATIC_FLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) + $(CXX) $(CXXFLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) @echo " === C++ DLL built: $@ ===" $(DLL_DIR): diff --git a/engines/src/fortran/Makefile b/engines/src/fortran/Makefile index a505886..a318c23 100644 --- a/engines/src/fortran/Makefile +++ b/engines/src/fortran/Makefile @@ -7,10 +7,14 @@ LIB_SRC = dynamics_lib.f90 UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) -ifeq ($(UNAME_S),Windows) - STATIC_FLAGS = -static -else - STATIC_FLAGS = +# Windows 检测:Msys2/MINGW 也视为 Windows +IS_WINDOWS := $(findstring MINGW,$(UNAME_S)) +ifneq ($(IS_WINDOWS),) + UNAME_S := Windows +endif +IS_WINDOWS := $(findstring MSYS,$(UNAME_S)) +ifneq ($(IS_WINDOWS),) + UNAME_S := Windows endif # DLL 输出到 engines/release/ @@ -23,8 +27,9 @@ else ifeq ($(UNAME_S),Darwin) DLL_TARGET = $(DLL_DIR)/dynamics_f90.dylib DLL_FLAGS = -dynamiclib else + # Windows: 完全静态链接,避免依赖 libgfortran-5.dll DLL_TARGET = $(DLL_DIR)/dynamics_f90.dll - DLL_FLAGS = -shared -fPIC + DLL_FLAGS = -shared -fPIC -static endif .PHONY: all dll clean @@ -34,7 +39,7 @@ all: dll dll: $(DLL_TARGET) $(DLL_TARGET): $(LIB_SRC) | $(DLL_DIR) - $(FC) $(FFLAGS) $(STATIC_FLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) + $(FC) $(FFLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) @echo " === Fortran DLL built: $@ ===" $(DLL_DIR):