Skip to content

Commit c4fa8f7

Browse files
committed
feat: Generate .def, .exp and .lib files when building for Windows
1 parent 74bbac5 commit c4fa8f7

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

cmake/StrictAbi.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function(_make_version_script target)
4848
endfunction()
4949

5050
option(STRICT_ABI "Enforce strict ABI export in dynamic libraries" OFF)
51-
if(WIN32 OR APPLE)
52-
# Windows and OSX don't have this linker functionality.
51+
if((WIN32 AND NOT MINGW) OR APPLE)
52+
# Windows and macOS don't have this linker functionality.
5353
set(STRICT_ABI OFF)
5454
endif()
5555

other/docker/windows/build_toxcore.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ build() {
7575
-DCMAKE_BUILD_TYPE="Release" \
7676
-DENABLE_SHARED=ON \
7777
-DENABLE_STATIC=ON \
78+
-DSTRICT_ABI=ON \
79+
-DEXPERIMENTAL_API=ON \
7880
-DCMAKE_EXE_LINKER_FLAGS="-static" \
7981
-DCMAKE_SHARED_LINKER_FLAGS="-static" \
8082
"${EXTRA_CMAKE_FLAGS_ARRAY[@]}" \
@@ -110,6 +112,23 @@ build() {
110112
fi
111113
fi
112114

115+
# generate def, lib and exp as they supposedly help with linking against the dlls,
116+
# especially the lib is supposed to be of great help when linking on msvc.
117+
# cd in order to keep the object names inside .lib and .dll.a short
118+
cd "$RESULT_PREFIX_DIR"/bin/
119+
for TOX_DLL in *.dll; do
120+
gendef - "$TOX_DLL" >"${TOX_DLL%.*}.def"
121+
# we overwrite the CMake-generated .dll.a for the better
122+
# compatibility with the .lib being generated here
123+
"$WINDOWS_TOOLCHAIN"-dlltool \
124+
--input-def "${TOX_DLL%.*}.def" \
125+
--output-lib "${TOX_DLL%.*}.lib" \
126+
--output-exp "${TOX_DLL%.*}.exp" \
127+
--output-delaylib "../lib/${TOX_DLL%.*}.dll.a" \
128+
--dllname "$TOX_DLL"
129+
done
130+
cd -
131+
113132
# move static dependencies
114133
cp -a "$DEP_PREFIX_DIR"/* "$RESULT_PREFIX_DIR"
115134

other/docker/windows/get_packages.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ apt-get install -y \
1717
libc-dev \
1818
libtool \
1919
make \
20+
mingw-w64-tools \
2021
pkg-config \
2122
tree \
2223
yasm

0 commit comments

Comments
 (0)