Skip to content

Commit 993a134

Browse files
committed
Enable static CRT linking for fully standalone executable
Changes: - Set CMAKE_MSVC_RUNTIME_LIBRARY to MultiThreaded (/MT flag) - Embeds C/C++ runtime into executable instead of using DLLs - Removes dependency on VCRUNTIME140.dll, MSVCP140.dll - Removes dependency on api-ms-win-crt-*.dll (Universal CRT) Result: - Before: Requires VC++ Redistributable installation - After: Fully standalone executable with only KERNEL32.dll dependency This applies to all submodules (Neptune, NThread, NThreadOSUtils) as well.
1 parent 4c92652 commit 993a134

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ set(CMAKE_CXX_STANDARD 11)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
77

8+
# Use static C/C++ runtime (/MT) instead of dynamic (/MD)
9+
# This embeds the runtime into the executable (no VCRUNTIME/MSVCP DLLs needed)
10+
if(MSVC)
11+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
12+
endif()
13+
814
add_subdirectory(Neptune)
915
add_subdirectory(NThread)
1016
add_subdirectory(NThreadOSUtils)
@@ -22,9 +28,6 @@ add_executable(${EXECUTABLE_NAME} ${GHOSTINJECTOR_SOURCES})
2228
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${GHOSTINJECTOR_INCLUDE_DIR})
2329
target_link_libraries(${EXECUTABLE_NAME} PRIVATE NThreadOSUtils)
2430

25-
# Dynamic linking - will use MSVC runtime DLLs (msvcp140.dll, vcruntime140.dll)
26-
# Removed: -static -static-libgcc -static-libstdc++
27-
2831
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE
2932
LOG_LEVEL_2
3033
NEPTUNE_MODULERULES_HEADER="ntosutils_rules.h"

0 commit comments

Comments
 (0)