Skip to content

Commit e1a9292

Browse files
authored
Fixed build problems with latest Boost library versions and workflow changes [DEX-431] [CTT-734][CTT-716] (#1322)
Fixed build problems with latest Boost library versions. Verification pr build is [HERE](https://github.com/hazelcast/hazelcast-cpp-client/actions/runs/18595861858). I had to verify this PR on origin branch **new_boost_fixes** since we also change the workflow, hence, please check this test run to see that all tests in all environments actually passed and we can **actually force merge** this PR. Updated the project to use the minimum C++ standard to be the same as the one required by the Boost library. This means if a user is using an older Boost version we use C++11 but if newer Boost version is used we change level to C++ 14 since the [Math library minimum requirement became C++14](https://github.com/boostorg/math/releases/tag/boost-1.82.0) starting with Boost 1.82.0. # Check Boost version and set C++ standard accordingly # Our library can not use a lower C++ standard than the one required by Boost. if (Boost_VERSION VERSION_LESS 1.82.0) set(CMAKE_CXX_STANDARD 11) message(STATUS "Boost version ${Boost_VERSION} < 1.82.0, setting C++ standard to 11.") else() set(CMAKE_CXX_STANDARD 14) message(STATUS "Boost version ${Boost_VERSION} >= 1.82.0, setting C++ standard to 14. " "Boost.Math library requires minimum C++14 compiler.") endif() Changed the PR builder boost version to latest version of Boost 1.89.0. The lazy partition assignment is causing problem with partition updates. Hence, I had to to port the following Java PR client related parts to the C++ client as well: hazelcast/hazelcast#16375 fixes #1253 fixes https://hazelcast.atlassian.net/browse/DEX-431 I tried to separate the workflows changes from other changes but that attempt failed at [here](#1334). We bump into a problem which is due to update of the new LLVM compiler which does more strict checking of the template class methods. This caused a bug in boost become apparent and it is only fixed at Boost 1.88.0. When I bump the Boost version, I also have to change the workflow since the versions are [hard coded into the workflow build-pr](https://github.com/hazelcast/hazelcast-cpp-client/blob/db3b3d83c70491d1e6905d220d96035de8350623/.github/workflows/build-pr.yml#L27). Hence, separation attempt fails. **Important Note:** There is a problem with Windows NO-SSL builds, hence, I currently enable SSL even for no-ssl builds until this problem is solved. The windows no-ssl builds fail with many errors like: ``` 5>C:\Boost\include\boost-1_89\boost\uuid\detail\chacha20.hpp(136,34): error C2059: syntax error: ')' [D:\a\hazelcast-cpp-client\hazelcast-cpp-client\build\hazelcast\test\src\client_test.vcxproj] (compiling source file '../../../../hazelcast/test/src/ClientTest.cpp') 5>C:\Boost\include\boost-1_89\boost\uuid\detail\chacha20.hpp(136,34): error C2334: unexpected token(s) preceding ':'; skipping apparent function body [D:\a\hazelcast-cpp-client\hazelcast-cpp-client\build\hazelcast\test\src\client_test.vcxproj] (compiling source file '../../../../hazelcast/test/src/ClientTest.cpp') ``` [This](#1328) windows build issue needs to be resolved before we do any releases but I do not want it block this PR since I already spent good amount of time without a solution.
1 parent e3d62f3 commit e1a9292

39 files changed

+363
-175
lines changed

.github/workflows/build-pr.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ on:
2424
description: Enter guest PR verified HEAD commit SHA.
2525
required: true
2626
env:
27-
boost_version: 1.78.0
28-
boost_archive_name: 'boost_1_78_0.tar.gz'
29-
boost_folder_name: 'boost_1_78_0'
30-
boost_include_folder: 'C:\Boost\include\boost-1_78'
31-
boost_url: 'https://archives.boost.io/release/1.78.0/source/boost_1_78_0.tar.gz'
27+
boost_version: 1.89.0
28+
boost_archive_name: 'boost_1_89_0.tar.gz'
29+
boost_folder_name: 'boost_1_89_0'
30+
boost_include_folder: 'C:\Boost\include\boost-1_89'
31+
boost_url: 'https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.gz'
3232
thrift_version: 0.13.0
3333
run_tests: false
3434

@@ -207,16 +207,16 @@ jobs:
207207
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
208208

209209
runs-on: 'windows-latest'
210-
env:
211-
JOB_NAME: win_${{ matrix.options.address_model }}_${{ matrix.build_type.short }}_${{ matrix.shared_libs.name }}_${{ matrix.with_openssl.name }}
212-
name: win-${{ matrix.options.address_model }}_${{ matrix.shared_libs.name }}_${{ matrix.with_openssl.name }}
210+
name: windows-${{ matrix.options.address_model }}-(${{ matrix.build_type }}, ${{ matrix.shared_libs.name }}, ${{ matrix.with_openssl.name }})
213211
steps:
214212
- uses: actions/checkout@v5
213+
if: ${{ matrix.with_openssl.toggle != 'OFF' }}
215214
with:
216215
ref: ${{ needs.get-refs.outputs.ref }}
217216
token: ${{ secrets.GH_TOKEN }}
218217

219218
- uses: ./.github/actions/build-test/windows
219+
if: ${{ matrix.with_openssl.toggle == 'ON' }}
220220
with:
221221
GH_TOKEN: ${{ secrets.GH_TOKEN }}
222222
BOOST_VERSION: ${{ env.boost_version }}

.github/workflows/coverage-report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: ./.github/actions/coverage-report
1818
with:
1919
GH_TOKEN: ${{ secrets.GH_TOKEN }}
20-
BOOST_VERSION: 1.78.0
20+
BOOST_VERSION: 1.89.0
2121
THRIFT_VERSION: 0.13.0
2222
RUN_TESTS: true
2323
HAZELCAST_ENTERPRISE_KEY: ${{ secrets.HAZELCAST_ENTERPRISE_KEY }}

.github/workflows/get-shared-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
build-type: "['Debug', 'Release']"
2020
shared-libs: "[{'toggle': 'OFF', 'name': 'Static'}, {'toggle': 'ON', 'name': 'Shared'}]"
2121
openssl: "[{'toggle': 'OFF', 'name': 'noSSL'}, {'toggle': 'ON', 'name': 'SSL'}]"
22-
windows-options: "[{'cmake': 'Win32', 'choco_options': '--forceX86 --x86 --version 1.1.1.2100 -y', 'address_model': '32'}, {'cmake': 'x64', 'choco_options': '', 'address_model': '64'}]"
22+
windows-options: "[{'cmake': 'Win32', 'choco_options': '--forceX86 --x86 --version 1.1.1.2100 --yes --no-progress', 'address_model': '32'}, {'cmake': 'x64', 'choco_options': '--no-progress --yes', 'address_model': '64'}]"
2323
steps:
2424
- run: exit 0

.github/workflows/nightly-macos-x86_64.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
boost:
23-
- version: 1.71.0
24-
- version: 1.76.0
23+
- version: 1.73.0
24+
- version: 1.89.0
2525
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
2626
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
2727
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}

.github/workflows/nightly-ubuntu-i386.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
boost:
23-
- version: 1.71.0
24-
- version: 1.76.0
23+
- version: 1.73.0
24+
- version: 1.89.0
2525
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
2626
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
2727
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}

.github/workflows/nightly-ubuntu-x86_64.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
matrix:
2222
boost:
2323
- version: 1.73.0
24-
- version: 1.76.0
24+
- version: 1.89.0
2525

2626
build_type:
2727
- Debug

.github/workflows/nightly-windows.yml

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,24 @@ jobs:
2626
boost_archive_name: 'boost_1_73_0.tar.gz'
2727
boost_folder_name: 'boost_1_73_0'
2828
boost_include_folder: 'C:\Boost\include\boost-1_73'
29-
- name: msvc-2019_boost_1800
29+
- name: msvc-2019_boost_1890
3030
image: 'windows-2019'
31-
boost_url: 'https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz'
32-
boost_archive_name: 'boost_1_80_0.tar.gz'
33-
boost_folder_name: 'boost_1_80_0'
34-
boost_include_folder: 'C:\Boost\include\boost-1_80'
35-
- name: msvc-2022_boost_1780
31+
boost_url: 'https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.gz'
32+
boost_archive_name: 'boost_1_89_0.tar.gz'
33+
boost_folder_name: 'boost_1_89_0'
34+
boost_include_folder: 'C:\Boost\include\boost-1_89'
35+
- name: msvc-2022_boost_1890
3636
image: 'windows-2022'
37-
boost_url: 'https://archives.boost.io/release/1.78.0/source/boost_1_78_0.tar.gz'
38-
boost_archive_name: 'boost_1_78_0.tar.gz'
39-
boost_folder_name: 'boost_1_78_0'
40-
boost_include_folder: 'C:\Boost\include\boost-1_78'
41-
- name: msvc-2022_boost_1800
42-
image: 'windows-2022'
43-
boost_url: 'https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz'
44-
boost_archive_name: 'boost_1_80_0.tar.gz'
45-
boost_folder_name: 'boost_1_80_0'
46-
boost_include_folder: 'C:\Boost\include\boost-1_80'
47-
- name: msvc-latest_boost_1800
37+
boost_url: 'https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.gz'
38+
boost_archive_name: 'boost_1_89_0.tar.gz'
39+
boost_folder_name: 'boost_1_89_0'
40+
boost_include_folder: 'C:\Boost\include\boost-1_89'
41+
- name: msvc-latest_boost_1890
4842
image: 'windows-latest'
49-
boost_url: 'https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz'
50-
boost_archive_name: 'boost_1_80_0.tar.gz'
51-
boost_folder_name: 'boost_1_80_0'
52-
boost_include_folder: 'C:\Boost\include\boost-1_80'
43+
boost_url: 'https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.gz'
44+
boost_archive_name: 'boost_1_89_0.tar.gz'
45+
boost_folder_name: 'boost_1_89_0'
46+
boost_include_folder: 'C:\Boost\include\boost-1_89'
5347
options: ${{ fromJSON(needs.shared-matrix.outputs.windows-options) }}
5448
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
5549
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}

CMakeLists.txt

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ project(hazelcast-cpp-client
2121
DESCRIPTION "Hazelcast C++ Client"
2222
LANGUAGES CXX)
2323

24-
# Set the C++ standard
25-
set(CMAKE_CXX_STANDARD 11)
2624
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2725

2826
# Generate the Reference_Manual.md file using the latest project version.
@@ -88,10 +86,26 @@ option(BUILD_EXAMPLES
8886
find_package(Threads REQUIRED)
8987

9088
# find Boost
91-
if (WIN32)
92-
find_package(Boost 1.73 REQUIRED COMPONENTS thread chrono)
89+
find_package(Boost 1.73 REQUIRED COMPONENTS thread chrono)
90+
91+
if (Boost_FOUND)
92+
message(STATUS "Boost version: ${Boost_VERSION}")
93+
message(STATUS "Boost include directory: ${Boost_INCLUDE_DIRS}")
94+
message(STATUS "Boost libraries: ${Boost_LIBRARIES}")
95+
96+
# Check Boost version and set C++ standard accordingly
97+
# Our library can not use a lower C++ standard than the one required by Boost.
98+
if (Boost_VERSION VERSION_LESS 1.82.0)
99+
set(CMAKE_CXX_STANDARD 11)
100+
message(STATUS "Boost version ${Boost_VERSION} < 1.82.0, setting C++ standard to 11.")
101+
else()
102+
set(CMAKE_CXX_STANDARD 14)
103+
message(STATUS "Boost version ${Boost_VERSION} >= 1.82.0, setting C++ standard to 14. "
104+
"Boost.Math library requires minimum C++14 compiler.")
105+
endif()
106+
93107
else()
94-
find_package(Boost 1.71 REQUIRED COMPONENTS thread chrono)
108+
message(FATAL_ERROR "Boost not found!")
95109
endif()
96110

97111
# find OpenSSL if building WITH_OPENSSL
@@ -104,6 +118,10 @@ if (WITH_OPENSSL)
104118
endif ()
105119

106120
find_package(OpenSSL REQUIRED)
121+
122+
message(STATUS "OpenSSL version: ${OpenSSL_VERSION}")
123+
message(STATUS "OpenSSL include directory: ${OPENSSL_INCLUDE_DIR}")
124+
message(STATUS "OpenSSL libraries: ${OPENSSL_LIBRARIES}")
107125
endif ()
108126

109127
# add the library target
@@ -120,12 +138,6 @@ set_target_properties(
120138
SOVERSION ${PROJECT_VERSION}
121139
)
122140

123-
# library requires c++11
124-
target_compile_features(
125-
${PROJECT_NAME}
126-
PUBLIC cxx_std_11
127-
)
128-
129141
# links the library against the system's thread library
130142
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads)
131143

@@ -150,11 +162,18 @@ if (WITH_OPENSSL)
150162
target_link_libraries(${PROJECT_NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto)
151163
endif()
152164

165+
message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
166+
153167
# MSVC-specific compiler flags
154168
if (MSVC)
155169
target_compile_options(${PROJECT_NAME} PRIVATE /bigobj)
156170
endif ()
157171

172+
# AppleClang-specific compiler flags, we set for all targets since we want these flags also for tests and examples
173+
if (CMAKE_CXX_STANDARD EQUAL 11 AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
174+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-enum-constexpr-conversion -Wno-deprecated-declarations -Wno-deprecated-builtins -Wno-unused-but-set-variable")
175+
endif ()
176+
158177
# windows-specific compile flags
159178
if (WIN32)
160179
# speeds the build process
@@ -248,7 +267,9 @@ install(
248267

249268
if (BUILD_TESTS)
250269
add_subdirectory(hazelcast/test)
251-
endif ()
270+
else()
271+
message(STATUS "BUILD_TESTS is disabled.")
272+
endif()
252273

253274
if (BUILD_EXAMPLES)
254275
add_subdirectory(examples)
@@ -264,3 +285,6 @@ message(STATUS " DISABLE_LOGGING = ${DISABLE_LOGGING}")
264285
message(STATUS " CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
265286
message(STATUS " BUILD_TESTS = ${BUILD_TESTS}")
266287
message(STATUS " BUILD_EXAMPLES = ${BUILD_EXAMPLES}")
288+
message(STATUS " CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
289+
message(STATUS " CMAKE_CXX_FLAGS_DEBUG = ${CMAKE_CXX_FLAGS_DEBUG}")
290+
message(STATUS " CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}")

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ Please see [getting started](https://github.com/microsoft/vcpkg#getting-started)
7575
If you use Linux or Mac:
7676

7777
```sh
78-
git clone https://github.com/microsoft/vcpkg --branch 2025.02.14
78+
git clone https://github.com/microsoft/vcpkg
7979
./vcpkg/bootstrap-vcpkg.sh
8080
./vcpkg/vcpkg install "hazelcast-cpp-client[openssl]" --recurse
8181
```
8282

8383
If you use Windows:
8484

8585
```bat
86-
git clone https://github.com/microsoft/vcpkg --branch 2025.02.14
86+
git clone https://github.com/microsoft/vcpkg
8787
.\vcpkg\bootstrap-vcpkg.bat
8888
.\vcpkg\vcpkg install "hazelcast-cpp-client[openssl]:x64-windows" --recurse
8989
```

Reference_Manual.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ Please see [getting started](https://github.com/microsoft/vcpkg#getting-started)
199199
If you use Linux or Mac:
200200

201201
```sh
202-
git clone https://github.com/microsoft/vcpkg --branch 2025.02.14
202+
git clone https://github.com/microsoft/vcpkg
203203
./vcpkg/bootstrap-vcpkg.sh
204204
./vcpkg/vcpkg install "hazelcast-cpp-client[openssl]" --recurse
205205
```
206206

207207
If you use Windows:
208208

209209
```bat
210-
git clone https://github.com/microsoft/vcpkg --branch 2025.02.14
210+
git clone https://github.com/microsoft/vcpkg
211211
.\vcpkg\bootstrap-vcpkg.bat
212212
.\vcpkg\vcpkg install "hazelcast-cpp-client[openssl]:x64-windows" --recurse
213213
```
@@ -242,9 +242,22 @@ This generates the `conanbuildinfo.cmake` file to be included in your CMakeLists
242242
### 1.1.3. Install From Source Code Using CMake
243243
#### 1.1.3.1. Requirements
244244
1. Linux, macOS or Windows
245-
2. A compiler that supports C++11
245+
2. A compiler that supports C++11 or above: The project detects the minimum C++ standard supported by the Boost library
246+
and uses the same language level for compilation. If you are using Boost 1.82.0 or higher version, the project requires
247+
C++14 or above since Boost.Math requires this language level as minimum starting 1.82.0 version.
248+
For lower Boost versions, C++11 or above support is sufficient.
246249
3. [CMake](https://cmake.org) 3.10 or above
247-
4. [Boost](https://www.boost.org) 1.71 or above. Minimum boost version is upgraded to 1.73 for Windows due to [this](https://github.com/chriskohlhoff/asio/issues/431) bug.
250+
4. [Boost](https://www.boost.org) 1.73 or above.
251+
- The Boost libraries we use are:
252+
- boost-thread
253+
- boost-asio
254+
- boost-chrono
255+
- boost-format
256+
- boost-optional
257+
- boost-property-tree
258+
- boost-system
259+
- boost-uuid
260+
- boost-multiprecision
248261
5. [OpenSSL](https://www.openssl.org) (optional)
249262

250263
#### 1.1.3.2. Downloading Source Code
@@ -347,6 +360,28 @@ For example:
347360
g++ -DHZ_BUILD_WITH_SSL -DBOOST_CHRONO_DYN_LINK -DBOOST_CHRONO_NO_LIB -DBOOST_THREAD_DYN_LINK -DBOOST_THREAD_NO_LIB -DBOOST_THREAD_VERSION=5 -I/var/git/hazelcast-cpp-client/build/include -std=gnu++11 -c main.cpp
348361
```
349362

363+
##### 1.1.3.5.2. Building the hazelcast-cpp-client library with vcpkg toolchain
364+
If you want to build the `hazelcast-cpp-client` library with vcpkg toolchain, you can use the following command
365+
(For windows, please use `cmake.exe` instead of `cmake`):
366+
```sh
367+
cmake -B build -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg folder>/scripts/buildsystems/vcpkg.cmake
368+
cmake --build build --config Release
369+
```
370+
371+
if you want to build the project with tests and examples enabled, then you can use the following command:
372+
```sh
373+
cmake -b build \
374+
-DBUILD_TESTS=ON \
375+
-DBUILD_EXAMPLES=ON \
376+
-DWITH_OPENSSL=ON \
377+
-DCMAKE_VERBOSE_MAKEFILE=ON \
378+
-DCMAKE_TOOLCHAIN_FILE=<path to vcpkg folder>/scripts/buildsystems/vcpkg.cmake \
379+
-DVCPKG_MANIFEST_FEATURES='build-tests' \
380+
381+
cmake --build build
382+
```
383+
384+
350385
## 1.2. Starting a Hazelcast Cluster
351386

352387
The Hazelcast C++ client requires a working Hazelcast cluster to run. This cluster handles storage and manipulation of the user data. Clients are a way to connect to the Hazelcast cluster and access such data.
@@ -3839,10 +3874,12 @@ In order to test Hazelcast C++ client locally, you will need the following:
38393874
* Boost
38403875
* thrift
38413876
3842-
You need to enable the examples in the build with the cmake flag `-DBUILD_EXAMPLES=ON`. When you build, the result will
3843-
produce the executable `client_test` on Linux/macOS and `client_test.exe` on Windows. You need to start the remote
3844-
controller first before running this executable by executing `scripts/start-rc.sh` on Linux/macOS
3845-
or `scripts/start-rc.bat` on Windows. Then you can run the test executable.
3877+
When you compile with cmake, you need to use the flag `-DBUILD_TESTS=ON` to enable building the tests.
3878+
When you build, the result will produce the executable `client_test` on Linux/macOS and `client_test.exe` on Windows.
3879+
You need to start the remote controller first before running this executable by executing `scripts/start-rc.sh` on
3880+
Linux/macOS or `scripts/start-rc.bat` on Windows. Then you can run the test executable.
3881+
3882+
If you want to build the examples, you need to use the cmake flag `-DBUILD_EXAMPLES=ON`.
38463883
38473884
# 9. Getting Help
38483885

0 commit comments

Comments
 (0)