@@ -93,17 +93,20 @@ deployment environment:
9393Example file name:
9494` client-cpp-2.0.7-SNAPSHOT-linux-x86_64-glibc224.zip ` .
9595
96- ** Linux ABI and glibc:** Two Linux families are published. ** ` glibc224 ` ** packages
97- are built on [ ` manylinux_2_24 ` ] ( https://github.com/pypa/manylinux ) with the
98- image default ` /usr/bin/g++ ` and the ** new** libstdc++ ABI (symbols contain
99- ` __cxx11 ` ); they require ** glibc ≥ 2.24** on the deployment host. Prefer these
100- on modern distros (Ubuntu 22.04+, Kylin V10, etc.) when your application uses
101- the default compiler ABI. ** ` glibc217 ` ** packages are built on ` manylinux2014 `
102- with ** ` -D_GLIBCXX_USE_CXX11_ABI=0 ` ** (no ` __cxx11 ` symbols) for hosts that only
103- have ** glibc 2.17** and cannot upgrade to 2.24+; your application must compile
104- with the same flag when linking against that SDK. The ` manylinux_2_24 ` image
105- series is ** EOL** ; it remains the oldest manylinux image that ships a gcc with
106- native cxx11 ABI support.
96+ ** Linux ABI and glibc:** Two Linux families are published.
97+
98+ | Package | manylinux image | Deployment glibc | libstdc++ ABI | How to match when you build your app |
99+ | ---------| -----------------| ------------------| ---------------| --------------------------------------|
100+ | ` *-glibc224 ` | ` manylinux_2_24 ` | ** ≥ 2.24** | ** cxx11** (` nm ` shows ` __cxx11 ` ) | Default g++ on Ubuntu 22.04+, Kylin V10, etc. — no extra flags |
101+ | ` *-glibc217 ` | ` manylinux2014 ` | ** ≥ 2.17** | ** legacy** (no ` __cxx11 ` ) | Add ** ` -D_GLIBCXX_USE_CXX11_ABI=0 ` ** to your compile flags |
102+
103+ Prefer ** ` glibc224 ` ** on modern distros. Use ** ` glibc217 ` ** only when the target
104+ host cannot run glibc 2.24+ binaries, or you must stay on the legacy ABI.
105+ The ` manylinux_2_24 ` image series is ** EOL** ; it is the oldest manylinux line
106+ used here that can produce a cxx11-ABI SDK with the image toolchain.
107+
108+ CI passes libstdc++ ABI into CMake via ** ` -Diotdb.extra.cxx.flags=... ` ** (see
109+ below). Setting ` CXXFLAGS ` alone is ** not** enough for the Maven/CMake build.
107110
108111Thrift ** 0.21.0** is compiled from source during the CMake configure step (see
109112` cmake/FetchThrift.cmake ` ). Older releases that used pre-built
@@ -114,21 +117,28 @@ and OS used to build** the SDK, not by that Maven property.
114117
115118### Local build for a specific classifier
116119
117- Linux x86_64 (glibc 2.24 + cxx11 ABI — match a modern distro or
118- ` manylinux_2_24 ` ):
120+ Linux x86_64 (** glibc224** , cxx11 ABI — modern distro or ` manylinux_2_24 ` ):
119121
120122``` bash
121123mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests \
122- -Dclient.cpp.package.classifier=linux-x86_64-glibc224 package
124+ -Dclient.cpp.package.classifier=linux-x86_64-glibc224 \
125+ -Diotdb.extra.cxx.flags=-D_GLIBCXX_USE_CXX11_ABI=1 package
123126```
124127
125- Linux x86_64 (glibc 2.17 + legacy ABI — CentOS 7 / manylinux2014; compile with
126- ` -D_GLIBCXX_USE_CXX11_ABI=0 ` ):
128+ Linux x86_64 (** glibc217** , legacy ABI — CentOS 7 / ` manylinux2014 ` ):
127129
128130``` bash
129- export CXXFLAGS=" -D_GLIBCXX_USE_CXX11_ABI=0"
130131mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests \
131- -Dclient.cpp.package.classifier=linux-x86_64-glibc217 package
132+ -Dclient.cpp.package.classifier=linux-x86_64-glibc217 \
133+ -Diotdb.extra.cxx.flags=-D_GLIBCXX_USE_CXX11_ABI=0 package
134+ ```
135+
136+ Standalone CMake (same ABI flags):
137+
138+ ``` bash
139+ cmake -S iotdb-client/client-cpp -B build \
140+ -DIOTDB_EXTRA_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=1 # or =0 for glibc217
141+ cmake --build build --target install
132142```
133143
134144Windows (match the Visual Studio version you use to build your application):
@@ -163,6 +173,7 @@ pass them as Maven properties (the POM maps them to `-D` options for CMake):
163173| ` BUILD_TESTING ` | ` build.tests ` |
164174| ` IOTDB_DEPS_DIR ` | ` iotdb.deps.dir ` |
165175| ` BOOST_INCLUDEDIR ` | ` boost.include.dir ` (legacy alias) |
176+ | ` IOTDB_EXTRA_CXX_FLAGS ` | ` iotdb.extra.cxx.flags ` (e.g. ` -D_GLIBCXX_USE_CXX11_ABI=0 ` ) |
166177
167178For a ** standalone** ` cmake ` configure, pass ` -DWITH_SSL=ON ` , ` -DIOTDB_OFFLINE=ON ` ,
168179etc. directly.
@@ -178,6 +189,7 @@ etc. directly.
178189| ` BOOST_ROOT ` | (unset) | Existing Boost install to reuse, equivalent to ` -Dboost.include.dir=... ` from the legacy build. |
179190| ` OPENSSL_ROOT_DIR ` | (unset) | Existing OpenSSL install when ` WITH_SSL=ON ` . |
180191| ` CMAKE_INSTALL_PREFIX ` | ` <build>/install ` | Install location. |
192+ | ` IOTDB_EXTRA_CXX_FLAGS ` | (empty) | Appended to ` CMAKE_CXX_FLAGS ` on Linux/macOS (libstdc++ ABI, etc.). Also applied to the Thrift sub-build. |
181193
182194## Online build (default)
183195
@@ -345,35 +357,75 @@ as a separate install artifact.
345357
346358## Using the C++ client
347359
360+ ### Application code
361+
348362``` cpp
349363#include " Session.h"
350- #include < memory >
351- #include < iostream >
352-
353- int main () {
354- auto session = std::make_shared<Session>("127.0.0.1", 6667, "root", "root");
355- session->open(false);
356- session->setStorageGroup("root.test01");
357- if (!session->checkTimeseriesExists("root.test01.d0.s0")) {
358- session->createTimeseries(
359- "root.test01.d0.s0",
360- TSDataType::INT64,
361- TSEncoding::RLE,
362- CompressionType::SNAPPY);
363- }
364- session->close();
365- }
364+ #include < iostream >
365+ #include < memory >
366+
367+ int main () {
368+ auto session = std::make_shared<Session >("127.0.0.1", 6667, "root", "root");
369+ session->open(false);
370+ session->setStorageGroup("root.test01");
371+ if (!session->checkTimeseriesExists("root.test01.d0.s0")) {
372+ session->createTimeseries(
373+ "root.test01.d0.s0",
374+ TSDataType::INT64,
375+ TSEncoding::RLE,
376+ CompressionType::SNAPPY);
377+ }
378+ session->close();
379+ }
366380```
367381
368- Compile against the produced SDK:
382+ ### Link against a pre-built zip (Linux)
383+
384+ 1 . Unzip ` client-cpp-<version>-<classifier>.zip ` and note ` include/ ` and ` lib/ ` .
385+ 2 . Pick the classifier that matches your machine (see table above).
386+ 3 . Compile with the ** same libstdc++ ABI** as the zip:
369387
370388``` bash
371- clang++ -O2 user-cpp-code.cpp \
372- -I/path/to/sdk/include \
373- -L/path/to/sdk/lib \
374- -liotdb_session -lpthread \
375- -Wl,-rpath,/path/to/sdk/lib \
376- -std=c++11
389+ SDK=/path/to/client-cpp-2.0.7-SNAPSHOT-linux-x86_64-glibc224
390+
391+ # glibc224 zip (default g++ ABI on modern Linux):
392+ g++ -std=c++11 -O2 -o myapp myapp.cpp \
393+ -I" ${SDK} /include" -L" ${SDK} /lib" -liotdb_session -lpthread \
394+ -Wl,-rpath," ${SDK} /lib"
395+
396+ # glibc217 zip (legacy ABI — required):
397+ g++ -std=c++11 -O2 -o myapp myapp.cpp \
398+ -D_GLIBCXX_USE_CXX11_ABI=0 \
399+ -I" ${SDK} /include" -L" ${SDK} /lib" -liotdb_session -lpthread \
400+ -Wl,-rpath," ${SDK} /lib"
377401```
378402
403+ If linking fails with ` undefined reference to ... __cxx11::basic_string ` , the zip
404+ ABI and your compiler flags do not match — switch zip (` glibc224 ` vs ` glibc217 ` )
405+ or add/remove ` -D_GLIBCXX_USE_CXX11_ABI=0 ` .
406+
407+ At runtime, ensure ` libiotdb_session.so ` is found (` LD_LIBRARY_PATH ` or
408+ ` -Wl,-rpath ` as above). Thrift is ** inside** the SDK shared library; you do not
409+ ship a separate ` libthrift.so ` .
410+
411+ ### Link after a local Maven/CMake build
412+
413+ Install tree: ` iotdb-client/client-cpp/target/install/{include,lib} ` .
414+
415+ ``` bash
416+ g++ -std=c++11 -O2 -o myapp myapp.cpp \
417+ -Iiotdb-client/client-cpp/target/install/include \
418+ -Liotdb-client/client-cpp/target/install/lib \
419+ -liotdb_session -lpthread \
420+ -Wl,-rpath," $PWD /iotdb-client/client-cpp/target/install/lib"
421+ ```
422+
423+ Use the same ` -D_GLIBCXX_USE_CXX11_ABI=... ` flag you passed when building the SDK
424+ (` -Diotdb.extra.cxx.flags=... ` ).
425+
426+ ### Examples
427+
428+ See [ client-cpp-example] ( ../../example/client-cpp-example/README.md ) for CMake
429+ projects that consume an unpacked SDK (` -DIOTDB_SDK_ROOT=... ` ).
430+
379431For full API documentation see the [ C++ Native API guide] ( https://iotdb.apache.org/UserGuide/latest/API/Programming-Cpp-Native-API.html ) .
0 commit comments