Skip to content

Commit 1600dfc

Browse files
boybookclaude
andcommitted
fix: static-link all dependencies into wsjtx_core.dll on Windows
Statically links MinGW runtimes (libgcc, libstdc++, libgfortran, libquadmath, libwinpthread) and FFTW into wsjtx_core.dll so it only depends on KERNEL32.dll and msvcrt.dll. This eliminates DLL conflicts when the user's PATH contains a different MinGW/MSYS2 installation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 638a32b commit 1600dfc

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,9 @@ jobs:
109109
if: runner.os == 'Windows'
110110
shell: msys2 {0}
111111
run: |
112-
# Copy wsjtx_core.dll and MinGW runtime DLLs to build/Release
112+
# All dependencies (FFTW, MinGW runtimes) are statically linked into
113+
# wsjtx_core.dll — only system DLLs (KERNEL32, msvcrt) remain as imports
113114
cp build-core/Release/wsjtx_core.dll build/Release/
114-
for dll in libgfortran-5.dll libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll libfftw3f-3.dll libfftw3f_threads-3.dll libquadmath-0.dll; do
115-
[ -f "/mingw64/bin/$dll" ] && cp "/mingw64/bin/$dll" build/Release/
116-
done
117115
118116
# Test
119117
- name: Run tests (Linux/macOS)
@@ -180,9 +178,7 @@ jobs:
180178
mkdir -p "$TARGET_DIR"
181179
cp build/Release/wsjtx_lib_nodejs.node "$TARGET_DIR/"
182180
cp build/Release/wsjtx_core.dll "$TARGET_DIR/"
183-
cp build/Release/*.dll "$TARGET_DIR/" 2>/dev/null || true
184181
185-
# build-info.json
186182
cat > "$TARGET_DIR/build-info.json" <<EOF
187183
{"platform":"${{ matrix.platform }}","arch":"${{ matrix.arch }}","build_time":"$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
188184
EOF

CMakeLists.txt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,27 +276,35 @@ target_include_directories(wsjtx_core PRIVATE
276276
${Boost_INCLUDE_DIRS}
277277
)
278278

279-
target_link_libraries(wsjtx_core PRIVATE
280-
wsjtx_lib
281-
${FFTW3F_LIBRARIES}
282-
)
279+
target_link_libraries(wsjtx_core PRIVATE wsjtx_lib)
283280

284281
# Platform-specific linking for wsjtx_core
285282
if(APPLE)
286-
target_link_libraries(wsjtx_core PRIVATE "-framework Accelerate" gfortran gcc_s.1)
283+
target_link_libraries(wsjtx_core PRIVATE
284+
${FFTW3F_LIBRARIES} "-framework Accelerate" gfortran gcc_s.1)
287285
if(FFTW_HAS_THREADS)
288286
target_link_libraries(wsjtx_core PRIVATE fftw3f_threads)
289287
endif()
290288
elseif(UNIX)
291-
target_link_libraries(wsjtx_core PRIVATE gfortran gcc_s pthread)
289+
target_link_libraries(wsjtx_core PRIVATE
290+
${FFTW3F_LIBRARIES} gfortran gcc_s pthread)
292291
if(FFTW_HAS_THREADS)
293292
target_link_libraries(wsjtx_core PRIVATE fftw3f_threads)
294293
endif()
295294
elseif(WIN32)
296-
target_link_libraries(wsjtx_core PRIVATE gfortran gcc_s pthread)
297-
if(FFTW_HAS_THREADS)
298-
target_link_libraries(wsjtx_core PRIVATE fftw3f_threads)
299-
endif()
295+
# Static-link ALL non-system dependencies so wsjtx_core.dll only depends
296+
# on Windows system DLLs (KERNEL32.dll, msvcrt.dll). This prevents DLL
297+
# conflicts when the user's PATH contains a different MinGW installation.
298+
target_link_options(wsjtx_core PRIVATE
299+
-static-libgcc
300+
-static-libstdc++
301+
)
302+
target_link_libraries(wsjtx_core PRIVATE
303+
-Wl,-Bstatic
304+
-lfftw3f -lfftw3f_threads
305+
-lgfortran -lquadmath -lwinpthread
306+
-Wl,-Bdynamic
307+
)
300308
endif()
301309

302310
# Output wsjtx_core to build/Release alongside .node

0 commit comments

Comments
 (0)