Skip to content

Commit f39ba16

Browse files
committed
Clarify C++ client build and usage docs
1 parent faba002 commit f39ba16

2 files changed

Lines changed: 100 additions & 69 deletions

File tree

iotdb-client/client-cpp/README.md

Lines changed: 88 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ example, link a `windows-x86_64-msvc14.3` package with Visual Studio 2022.
9595

9696
Visual Studio users can either open the project folder and add the unpacked SDK
9797
directory to `CMAKE_PREFIX_PATH` in CMake cache settings, or configure from a
98-
Developer Command Prompt:
98+
Developer Command Prompt. Use the same configuration (`Release` or `Debug`) as
99+
the SDK package you unpacked, and copy the runtime DLL next to your executable:
99100

100101
```bat
101102
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 ^
@@ -207,9 +208,9 @@ by default. Start IoTDB before running them.
207208

208209
- Linux release packages are built in the `manylinux_2_28` container and require
209210
glibc 2.28 or newer.
210-
- Windows packages use the dynamic MSVC runtime (`/MD`). Install the Microsoft
211-
Visual C++ Redistributable matching your Visual Studio generation on target
212-
machines that do not already have it.
211+
- Windows Release packages use the dynamic MSVC runtime (`/MD`); Debug
212+
packages use the debug runtime (`/MDd`) and are intended for local
213+
development with a matching Debug application.
213214
- Put `libiotdb_session.so`, `libiotdb_session.dylib`, or `iotdb_session.dll`
214215
next to your executable, or configure the platform library search path. On
215216
Linux, keep the `libiotdb_session.so*` symlink chain together when copying
@@ -252,23 +253,78 @@ During configure CMake will, in order:
252253
6. `cmake --install` lays out the SDK under `target/install/{include,lib}`,
253254
which Maven's assembly step packages into a zip.
254255

255-
### Build matrix
256+
### Maven build
256257

257-
| Goal | Command |
258-
|-------------------------------|--------------------------------------------------------------------------------------------------------|
259-
| Library only (Linux/macOS) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests package` |
260-
| Debug library (Linux/macOS) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests -Dcmake.build.type=Debug package` |
261-
| Library only (Windows / MSVC) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests "-Dboost.include.dir=C:\boost_1_88_0" package` |
262-
| Debug library (Windows / MSVC) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests -Dcmake.build.type=Debug "-Dboost.include.dir=C:\boost_1_88_0" package` |
263-
| Library + ITs (Linux/macOS) | `mvn clean install -P with-cpp -pl distribution,iotdb-client/client-cpp -am` then `mvn -P with-cpp -pl iotdb-client/client-cpp -am verify` |
264-
| Direct CMake (no Maven) | `cmake -S iotdb-client/client-cpp -B build && cmake --build build --target install` |
258+
The Maven wrapper configures CMake, builds the SDK, installs it under
259+
`iotdb-client/client-cpp/target/install/`, and packages a zip at
260+
`iotdb-client/client-cpp/target/iotdb-session-cpp-<version>-<classifier>.zip`
261+
with a `.sha512` checksum generated alongside.
265262

266-
The Maven build sets `cmake.install.prefix` to `target/install/`. Output zips
267-
land at `iotdb-client/client-cpp/target/iotdb-session-cpp-<version>-<classifier>.zip`
268-
(with a package root directory and a `.sha512` checksum generated alongside).
263+
Linux/macOS:
264+
265+
```bash
266+
# Release
267+
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests package
268+
269+
# Debug
270+
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests \
271+
-Dcmake.build.type=Debug package
272+
```
273+
274+
Windows PowerShell:
275+
276+
```powershell
277+
# Release
278+
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests `
279+
"-Dboost.include.dir=C:\boost_1_88_0" package
280+
281+
# Debug
282+
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests `
283+
"-Dcmake.build.type=Debug" `
284+
"-Dboost.include.dir=C:\boost_1_88_0" package
285+
```
286+
287+
Quote Maven `-D...` arguments that contain dots when running from PowerShell.
288+
For `cmd.exe`, keep each command on one line or use `^` for line continuation.
269289
The classifier can be overridden with `-Dclient.cpp.package.classifier=...` when
270290
building multiple toolchains on the same platform.
271291

292+
### Direct CMake build
293+
294+
Use direct CMake when you only need an installed SDK layout and do not need the
295+
Maven-generated zip/checksum.
296+
297+
Linux/macOS:
298+
299+
```bash
300+
# Release
301+
cmake -S iotdb-client/client-cpp -B build -DCMAKE_BUILD_TYPE=Release
302+
cmake --build build --target install
303+
304+
# Debug
305+
cmake -S iotdb-client/client-cpp -B build -DCMAKE_BUILD_TYPE=Debug
306+
cmake --build build --target install
307+
```
308+
309+
Windows with Visual Studio:
310+
311+
```powershell
312+
# Release
313+
cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64 `
314+
-DBOOST_ROOT="C:\boost_1_88_0"
315+
cmake --build build --config Release --target install
316+
317+
# Debug
318+
cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64 `
319+
-DCMAKE_BUILD_TYPE=Debug `
320+
-DBOOST_ROOT="C:\boost_1_88_0"
321+
cmake --build build --config Debug --target install
322+
```
323+
324+
For Visual Studio generators, `--config` selects the final SDK configuration.
325+
Set `CMAKE_BUILD_TYPE=Debug` during configure for Debug builds as well, because
326+
the top-level build uses it when building bundled third-party static libraries.
327+
272328
### Release packages (CI)
273329

274330
The [C++ Client package](../../.github/workflows/client-cpp-package.yml) workflow
@@ -309,51 +365,32 @@ and OS used to build** the SDK, not by that Maven property.
309365

310366
### Local build for a specific classifier
311367

312-
Linux x86_64 (glibc 2.28 baseline, matching the manylinux_2_28 release build):
368+
The default classifier is chosen from the host OS. Override it explicitly when
369+
you are building release artifacts for a specific target:
313370

314371
```bash
315372
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests \
316373
-Dclient.cpp.package.classifier=linux-x86_64-glibc2.28 package
317374
```
318375

319-
Debug build:
320-
321-
```bash
322-
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests \
323-
-Dcmake.build.type=Debug package
324-
```
325-
326-
Direct CMake Debug builds use the same build type. On Linux/macOS, pass
327-
`-DCMAKE_BUILD_TYPE=Debug` during configure. On Windows with Visual Studio,
328-
also pass `-DCMAKE_BUILD_TYPE=Debug` during configure so the bundled Thrift
329-
static library is built with the Debug MSVC runtime, then build with
330-
`--config Debug`:
331-
332-
```bash
333-
# Linux/macOS
334-
cmake -S iotdb-client/client-cpp -B build -DCMAKE_BUILD_TYPE=Debug
335-
cmake --build build --target install
336-
337-
# Windows / Visual Studio
338-
cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Debug
339-
cmake --build build --config Debug --target install
340-
```
341-
342376
Windows (match the Visual Studio version you use to build your application):
343377

344378
```powershell
345379
# Visual Studio 2022 (default on recent Windows)
346-
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests package
380+
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests `
381+
"-Dboost.include.dir=C:\boost_1_88_0" package
347382
348383
# Visual Studio 2019
349384
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests `
350-
-Dcmake.generator="Visual Studio 16 2019" `
351-
-Dclient.cpp.package.classifier=windows-x86_64-msvc14.2 package
385+
"-Dboost.include.dir=C:\boost_1_88_0" `
386+
"-Dcmake.generator=Visual Studio 16 2019" `
387+
"-Dclient.cpp.package.classifier=windows-x86_64-msvc14.2" package
352388
353389
# Visual Studio 2017 (CMake uses -A x64 on Windows automatically)
354390
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests `
355-
-Dcmake.generator="Visual Studio 15 2017" `
356-
-Dclient.cpp.package.classifier=windows-x86_64-msvc14.1 package
391+
"-Dboost.include.dir=C:\boost_1_88_0" `
392+
"-Dcmake.generator=Visual Studio 15 2017" `
393+
"-Dclient.cpp.package.classifier=windows-x86_64-msvc14.1" package
357394
```
358395

359396
On Windows, the build passes `-DCMAKE_GENERATOR_PLATFORM=x64` so Visual Studio
@@ -401,25 +438,8 @@ CMake will download any missing tarball at configure time. The first run is
401438
slow (≈100 MB download + a Thrift build); subsequent runs reuse the
402439
extracted artifacts under `build/_deps/`.
403440

404-
```bash
405-
# Linux / macOS
406-
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests package
407-
408-
# Windows (Developer Command Prompt for VS, PowerShell, or cmd)
409-
mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests "-Dboost.include.dir=C:\boost_1_88_0" package
410-
```
411-
412-
Standalone CMake uses the same online dependency resolution:
413-
414-
```bash
415-
# Linux / macOS
416-
cmake -S iotdb-client/client-cpp -B build -DCMAKE_BUILD_TYPE=Release
417-
cmake --build build --target install
418-
419-
# Windows / Visual Studio
420-
cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64
421-
cmake --build build --config Release --target install
422-
```
441+
Use the Maven or direct CMake commands above. Both build paths use the same
442+
online dependency resolution.
423443

424444
## Offline build
425445

@@ -497,9 +517,10 @@ Prerequisites:
497517
pass `-DOPENSSL_ROOT_DIR=...` to CMake.
498518

499519
On Windows the SDK ships as **`iotdb_session.dll`** plus an import library
500-
**`iotdb_session.lib`**, built with **`/MD`** (dynamic CRT, same as a
501-
default Visual Studio application). Thrift is linked into the DLL; users
502-
do not install separate Thrift headers or libraries. Place
520+
**`iotdb_session.lib`**. Release SDKs are built with **`/MD`** (dynamic CRT,
521+
same as a default Release Visual Studio application); Debug SDKs are built with
522+
**`/MDd`** and should be linked by Debug applications. Thrift is linked into the
523+
DLL; users do not install separate Thrift headers or libraries. Place
503524
`iotdb_session.dll` next to your `.exe` or on `PATH`.
504525

505526
Auto-building m4/flex/bison from tarball is **not** supported on Windows;

iotdb-client/client-cpp/README_zh.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ CMake 的包装;没有 Maven 时也可以直接使用 CMake。
223223
| 只构建库(Linux/macOS) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests package` |
224224
| 构建 Debug 库(Linux/macOS) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests -Dcmake.build.type=Debug package` |
225225
| 只构建库(Windows / MSVC) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests "-Dboost.include.dir=C:\boost_1_88_0" package` |
226-
| 构建 Debug 库(Windows / MSVC) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests -Dcmake.build.type=Debug "-Dboost.include.dir=C:\boost_1_88_0" package` |
226+
| 构建 Debug 库(Windows / MSVC) | `mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests "-Dcmake.build.type=Debug" "-Dboost.include.dir=C:\boost_1_88_0" package` |
227227
| 直接使用 CMake | `cmake -S iotdb-client/client-cpp -B build && cmake --build build --target install` |
228228

229229
Maven 构建会把 SDK 安装到 `target/install/`,并生成
@@ -250,11 +250,21 @@ Studio 生成器时也需要传入该选项,以便内置 Thrift 静态库使
250250

251251
```bash
252252
# Linux/macOS
253+
# Release
254+
cmake -S iotdb-client/client-cpp -B build -DCMAKE_BUILD_TYPE=Release
255+
cmake --build build --target install
256+
257+
# Debug
253258
cmake -S iotdb-client/client-cpp -B build -DCMAKE_BUILD_TYPE=Debug
254259
cmake --build build --target install
255260

256261
# Windows / Visual Studio
257-
cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Debug
262+
# Release
263+
cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64 -DBOOST_ROOT="C:\boost_1_88_0"
264+
cmake --build build --config Release --target install
265+
266+
# Debug
267+
cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Debug -DBOOST_ROOT="C:\boost_1_88_0"
258268
cmake --build build --config Debug --target install
259269
```
260270

0 commit comments

Comments
 (0)