Skip to content

Commit 0af38d1

Browse files
win*.sh,cmake: Fix Windows linking errors
The Windows build is hitting linking errors after bumping the Boost version to 1.75. The issue is that Boost is now setting the zlib dependecy using INTERFACE_LINK_LIBRARIES, which means that it's no longer located using the standard "find_package" mechanism. In order for the linker to locate zlib, we'll add it to the linker search path. [1] boostorg/boost_install#47 Signed-off-by: Lucian Petrut <[email protected]>
1 parent c6404e1 commit 0af38d1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ if(MINGW)
5252
set(CMAKE_CXX_LINK_EXECUTABLE
5353
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
5454

55+
link_directories(${MINGW_LINK_DIRECTORIES})
5556
endif()
5657

5758
option(WITH_CCACHE "Build with ccache.")

win32_build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ dokanLibDir="${depsToolsetDir}/dokany/lib"
9696
depsDirs="$lz4Dir;$curlDir;$sslDir;$boostDir;$zlibDir;$backtraceDir;$snappyDir"
9797
depsDirs+=";$winLibDir"
9898

99+
# Cmake recommends using CMAKE_PREFIX_PATH instead of link_directories.
100+
# Still, some library dependencies may not include the full path (e.g. Boost
101+
# sets the "-lz" flag through INTERFACE_LINK_LIBRARIES), which is why
102+
# we have to ensure that the linker will be able to locate them.
103+
linkDirs="$zlibDir/lib"
104+
99105
lz4Lib="${lz4Dir}/lib/dll/liblz4-1.dll"
100106
lz4Include="${lz4Dir}/lib"
101107
curlLib="${curlDir}/lib/libcurl.dll.a"
@@ -149,6 +155,7 @@ fi
149155
# symbols. Until we fix the dependencies (which are either unspecified
150156
# or circular), we'll have to stick to static linking.
151157
cmake -D CMAKE_PREFIX_PATH=$depsDirs \
158+
-D MINGW_LINK_DIRECTORIES="$linkDirs" \
152159
-D CMAKE_TOOLCHAIN_FILE="$MINGW_CMAKE_FILE" \
153160
-D WITH_LIBCEPHSQLITE=OFF \
154161
-D WITH_RDMA=OFF -D WITH_OPENLDAP=OFF \

0 commit comments

Comments
 (0)