在看pg_clickhouse插件的时候,看到这个项目
https://github.com/clickHouse/clickhouse-cpp/
虽然clickhouse二进制文件既能当服务器,又能当客户端,但是文件尺寸太大了,这个只保留了客户端,而且还能在windows上编译。
1.下载源代码
https://codeload.github.com/ClickHouse/clickhouse-cpp/zip/refs/heads/master
按照存储库的说明编译,注意[-DBUILD_TESTS=ON]选项中的[]表示可选,实际命令行要去掉,否则出现警告。
root@6ae32a5ffcde:/par# cd clickhouse-cpp
root@6ae32a5ffcde:/par/clickhouse-cpp# mkdir build
root@6ae32a5ffcde:/par/clickhouse-cpp# cd build
root@6ae32a5ffcde:/par/clickhouse-cpp/build# export PATH=$PATH:/par/cmake43L/bin
root@6ae32a5ffcde:/par/clickhouse-cpp/build# cmake .. [-DBUILD_TESTS=ON]
CMake Warning:
Ignoring extra path from command line:
"[-DBUILD_TESTS=ON]"
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
absl::int128 properties:
INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/absl
BINARY_DIR : /par/clickhouse-cpp/build/contrib/absl/absl
INTERFACE_INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
cityhash::cityhash properties:
INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/lz4/lz4;/par/clickhouse-cpp/contrib/cityhash/cityhash
BINARY_DIR : /par/clickhouse-cpp/build/contrib/cityhash/cityhash
INTERFACE_INCLUDE_DIRECTORIES : PROPERTY-NOTFOUND
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
lz4::lz4 properties:
INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/lz4/lz4
BINARY_DIR : /par/clickhouse-cpp/build/contrib/lz4/lz4
INTERFACE_INCLUDE_DIRECTORIES : PROPERTY-NOTFOUND
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
zstd::zstd properties:
INCLUDE_DIRECTORIES : /legacy;/par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/lz4/lz4;/par/clickhouse-cpp/contrib/cityhash/cityhash;/par/clickhouse-cpp/contrib/zstd/zstd;/par/clickhouse-cpp/contrib/zstd
BINARY_DIR : /par/clickhouse-cpp/build/contrib/zstd/zstd
INTERFACE_INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/zstd
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /par/clickhouse-cpp/build
root@6ae32a5ffcde:/par/clickhouse-cpp/build# make
[100%] Linking CXX static library libclickhouse-cpp-lib.a
[100%] Built target clickhouse-cpp-lib
root@6ae32a5ffcde:/par/clickhouse-cpp/build#
root@6ae32a5ffcde:/par/clickhouse-cpp/build# cmake .. -DBUILD_TESTS=ON
...
-- Configuring done
-- Generating done
-- Build files have been written to: /par/clickhouse-cpp/build
root@6ae32a5ffcde:/par/clickhouse-cpp/build# make -j8
[100%] Linking CXX executable clickhouse-cpp-ut
[100%] Built target clickhouse-cpp-ut
不加选项编译主要就是生成libclickhouse-cpp-lib.a静态库文件,-DBUILD_TESTS=ON选项编译出的单元测试二进制文件可以执行。
root@6ae32a5ffcde:/par/clickhouse-cpp/build# cd ut
root@6ae32a5ffcde:/par/clickhouse-cpp/build/ut# ./clickhouse-cpp-ut
[==========] Running 750 tests from 68 test suites.
[----------] Global test environment set-up.
[----------] 5 tests from BlockTest
[ RUN ] BlockTest.Iterator
[ OK ] BlockTest.Iterator (4 ms)
[ RUN ] BlockTest.RangeBasedForLoop
[ OK ] BlockTest.RangeBasedForLoop (0 ms)
[ RUN ] BlockTest.Iterators
[ OK ] BlockTest.Iterators (0 ms)
[ RUN ] BlockTest.Clear
[ OK ] BlockTest.Clear (0 ms)
[ RUN ] BlockTest.Reserve
[ OK ] BlockTest.Reserve (0 ms)
[----------] 5 tests from BlockTest (4 ms total)
[----------] 2 tests from SimpleClientTest
[ RUN ] SimpleClientTest.issue_335
unknown file: Failure
C++ exception with description "fail to connect: Connection refused" thrown in the test body.
[ FAILED ] SimpleClientTest.issue_335 (16 ms)
[ RUN ] SimpleClientTest.issue_335_reconnects_count
[ OK ] SimpleClientTest.issue_335_reconnects_count (20017 ms)
[----------] 2 tests from SimpleClientTest (20034 ms total)
^C
如果clickhouse服务器没有运行,很快就会报连接错,在另一个控制台窗口用clickhouse server命令启动clickhouse服务器。然后就能顺利测试了。
root@6ae32a5ffcde:/par/clickhouse-cpp/build/ut# ./clickhouse-cpp-ut
[==========] Running 750 tests from 68 test suites.
[----------] Global test environment set-up.
[----------] 5 tests from BlockTest
[ RUN ] BlockTest.Iterator
[ OK ] BlockTest.Iterator (3 ms)
[ RUN ] BlockTest.RangeBasedForLoop
[ OK ] BlockTest.RangeBasedForLoop (0 ms)
[ RUN ] BlockTest.Iterators
[ OK ] BlockTest.Iterators (0 ms)
[ RUN ] BlockTest.Clear
[ OK ] BlockTest.Clear (0 ms)
[ RUN ] BlockTest.Reserve
[ OK ] BlockTest.Reserve (0 ms)
[----------] 5 tests from BlockTest (3 ms total)
....
[ RUN ] Client/ClientCase.Query_ID/0
unknown file: Failure
C++ exception with description "DB::Exception: Unknown table expression identifier 'system.query_log' in scope SELECT type, query_kind, query_id, query FROM system.query_log WHERE (type = 'QueryStart') AND (query_id = '486347969-Client/ClientCase/Query_ID/0')" thrown in the test body.
[ FAILED ] Client/ClientCase.Query_ID/0, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:1 send_retries:1 retry_timeout:5 compression_method:None) (69 ms)
[ RUN ] Client/ClientCase.Query_ID/1
unknown file: Failure
C++ exception with description "DB::Exception: Unknown table expression identifier 'system.query_log' in scope SELECT type, query_kind, query_id, query FROM system.query_log WHERE (type = 'QueryStart') AND (query_id = '486347969-Client/ClientCase/Query_ID/1')" thrown in the test body.
[ FAILED ] Client/ClientCase.Query_ID/1, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:0 send_retries:1 retry_timeout:5 compression_method:LZ4) (9 ms)
[ RUN ] Client/ClientCase.OnProgress/0
[ OK ] Client/ClientCase.OnProgress/0 (2 ms)
[ RUN ] Client/ClientCase.OnProgress/1
[ OK ] Client/ClientCase.OnProgress/1 (2 ms)
[ RUN ] Client/ClientCase.QuerySettings/0
[ OK ] Client/ClientCase.QuerySettings/0 (45 ms)
[ RUN ] Client/ClientCase.QuerySettings/1
[ OK ] Client/ClientCase.QuerySettings/1 (6 ms)
[ RUN ] Client/ClientCase.ServerLogs/0
[ OK ] Client/ClientCase.ServerLogs/0 (3 ms)
[ RUN ] Client/ClientCase.ServerLogs/1
[ OK ] Client/ClientCase.ServerLogs/1 (2 ms)
[ RUN ] Client/ClientCase.TracingContext/0
unknown file: Failure
C++ exception with description "DB::Exception: Unknown table expression identifier 'system.opentelemetry_span_log' in scope SELECT trace_id, toString(trace_id), operation_name FROM system.opentelemetry_span_log WHERE trace_id = toUUID('00000000-6e98-8b60-0000-0000000b440c')" thrown in the test body.
[ FAILED ] Client/ClientCase.TracingContext/0, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:1 send_retries:1 retry_timeout:5 compression_method:None) (3 ms)
[ RUN ] Client/ClientCase.TracingContext/1
unknown file: Failure
C++ exception with description "DB::Exception: Unknown table expression identifier 'system.opentelemetry_span_log' in scope SELECT trace_id, toString(trace_id), operation_name FROM system.opentelemetry_span_log WHERE trace_id = toUUID('00000000-6e98-8b60-0000-0000000b440c')" thrown in the test body.
[ FAILED ] Client/ClientCase.TracingContext/1, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:0 send_retries:1 retry_timeout:5 compression_method:LZ4) (3 ms)
...
[----------] Global test environment tear-down
[==========] 750 tests from 68 test suites ran. (124904 ms total)
[ PASSED ] 742 tests.
[ SKIPPED ] 2 tests, listed below:
[ SKIPPED ] Socketcase.connecttimeout
[ SKIPPED ] GenericColumnTest/32.NullableT_RoundTrip
[ FAILED ] 6 tests, listed below:
[ FAILED ] Client/ClientCase.Query_ID/0, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:1 send_retries:1 retry_timeout:5 compression_method:None)
[ FAILED ] Client/ClientCase.Query_ID/1, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:0 send_retries:1 retry_timeout:5 compression_method:LZ4)
[ FAILED ] Client/ClientCase.TracingContext/0, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:1 send_retries:1 retry_timeout:5 compression_method:None)
[ FAILED ] Client/ClientCase.TracingContext/1, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:0 send_retries:1 retry_timeout:5 compression_method:LZ4)
[ FAILED ] Client/ClientCase.ClientName/0, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:1 send_retries:1 retry_timeout:5 compression_method:None)
[ FAILED ] Client/ClientCase.ClientName/1, where GetParam() = Client( Endpoints : [default@localhost:9000] (1 items ) ping_before_query:0 send_retries:1 retry_timeout:5 compression_method:LZ4)
6 FAILED TESTS
YOU HAVE 4 DISABLED TESTS
750个测试通过了742个,2个跳过,6个失败的。
-
利用编译出的静态库编译自定义的读写clickHouse数据库的cpp文件出错。都和上述第一步cmake的PROPERTY-NOTFOUND有关。
root@6ae32a5ffcde:/par/clickhouse-cpp/build/ut# cd ..
root@6ae32a5ffcde:/par/clickhouse-cpp/build# cd ..
root@6ae32a5ffcde:/par/clickhouse-cpp# g++ app.cpp -L /par/clickhouse-cpp/build/clickhouse -lclickhouse-cpp-lib -I /par/clickhouse-cpp/
/usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(types.cpp.o): in functionclickhouse::Type::GetTypeUniqueId() const': /par/clickhouse-cpp/clickhouse/types/types.cpp:169: undefined reference toCityHash64WithSeed(char const*, unsigned long, unsigned long)'
/usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(compressed.cpp.o): in functionclickhouse::CompressedOutput::Compress(void const*, unsigned long)': /par/clickhouse-cpp/clickhouse/base/compressed.cpp:175: undefined reference toLZ4_compress_default'
/usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:218: undefined reference toCityHash128(char const*, unsigned long)' /usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:199: undefined reference toZSTD_compress'
/usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:205: undefined reference toZSTD_isError' /usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(compressed.cpp.o): in functionclickhouse::CompressedOutput::PreallocateCompressBuffer(unsigned long)':
/par/clickhouse-cpp/clickhouse/base/compressed.cpp:243: undefined reference toZSTD_compressBound' /usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:244: undefined reference toZSTD_isError'
/usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:234: undefined reference toLZ4_compressBound' /usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(compressed.cpp.o): in functionclickhouse::CompressedInput::Decompress()':
/par/clickhouse-cpp/clickhouse/base/compressed.cpp:99: undefined reference toCityHash128(char const*, unsigned long)' /usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:108: undefined reference toLZ4_decompress_safe'
/usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:117: undefined reference toZSTD_decompress' /usr/bin/ld: /par/clickhouse-cpp/clickhouse/base/compressed.cpp:119: undefined reference toZSTD_isError'
/usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(compressed.cpp.o): in functionclickhouse::CompressedOutput::Compress(void const*, unsigned long)': /par/clickhouse-cpp/clickhouse/base/compressed.cpp:207: undefined reference toZSTD_getErrorName'
/usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(compressed.cpp.o): in functionclickhouse::CompressedOutput::PreallocateCompressBuffer(unsigned long)': /par/clickhouse-cpp/clickhouse/base/compressed.cpp:245: undefined reference toZSTD_getErrorName'
/usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(compressed.cpp.o): in functionclickhouse::CompressedInput::Decompress()': /par/clickhouse-cpp/clickhouse/base/compressed.cpp:120: undefined reference toZSTD_getErrorName'
/usr/bin/ld: /par/clickhouse-cpp/build/clickhouse/libclickhouse-cpp-lib.a(lowcardinality.cpp.o): in functionclickhouse::ColumnLowCardinality::computeHashKey(clickhouse::ItemView const&)': /par/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp:274: undefined reference toCityHash64(char const*, unsigned long)'
/usr/bin/ld: /par/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp:274: undefined reference toCityHash64(char const*, unsigned long)' /usr/bin/ld: /par/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp:274: undefined reference toCityHash64(char const*, unsigned long)'
/usr/bin/ld: /par/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp:274: undefined reference to `CityHash64(char const*, unsigned long)'
collect2: error: ld returned 1 exit status
按照存储库说明编写CMakeLists.txt,将add_subdirectory(contribs/clickhouse-cpp)改为add_subdirectory(.../clickhouse-cpp)引用第一步解压目录则报错
root@6ae32a5ffcde:/par/clickhouse-cpp# cd ..
root@6ae32a5ffcde:/par# mkdir clickhouse-app
root@6ae32a5ffcde:/par# cp /par/clickhouse-cpp/app.cpp clickhouse-app
root@6ae32a5ffcde:/par# cd clickhouse-app
root@6ae32a5ffcde:/par/clickhouse-app# cmake -B build -S .
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:6 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory "/par/clickhouse-cpp" is not a subdirectory of
"/par/clickhouse-app". When specifying an out-of-tree source a binary
directory must be explicitly specified.
-- Configuring incomplete, errors occurred!
See also "/par/clickhouse-app/build/CMakeFiles/CMakeOutput.log".
在网上搜索错误提示When specifying an out-of-tree source a binary directory must be explicitly specified, 找到了解决办法:
add_subdirectory还有一个 binary_dir参数,这个参数用来指定source_dir在输出文件夹中的位置,如果没有指定的时候,就用source_dir的值。 如果要添加外部文件夹则binary_dir就必须指定。
随便指定一个目录,比如third做第二个参数就行了。
cmake_minimum_required(VERSION 3.12)
project(application-example)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(../clickhouse-cpp ./third)
add_executable(${PROJECT_NAME} "app.cpp")
target_include_directories(${PROJECT_NAME} PRIVATE ../clickhouse-cpp/ ../clickhouse-cpp/contrib/absl)
target_link_libraries(${PROJECT_NAME} PRIVATE clickhouse-cpp-lib)
改完的结果如上,就可以顺利用cmake生成Makefile了。
root@6ae32a5ffcde:/par/clickhouse-app# cmake -B build -S .
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
absl::int128 properties:
INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/absl
BINARY_DIR : /par/clickhouse-app/build/third/contrib/absl/absl
INTERFACE_INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
cityhash::cityhash properties:
INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/lz4/lz4;/par/clickhouse-cpp/contrib/cityhash/cityhash
BINARY_DIR : /par/clickhouse-app/build/third/contrib/cityhash/cityhash
INTERFACE_INCLUDE_DIRECTORIES : PROPERTY-NOTFOUND
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
lz4::lz4 properties:
INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/lz4/lz4
BINARY_DIR : /par/clickhouse-app/build/third/contrib/lz4/lz4
INTERFACE_INCLUDE_DIRECTORIES : PROPERTY-NOTFOUND
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
zstd::zstd properties:
INCLUDE_DIRECTORIES : /legacy;/par/clickhouse-cpp/contrib/absl;/par/clickhouse-cpp/contrib/lz4/lz4;/par/clickhouse-cpp/contrib/cityhash/cityhash;/par/clickhouse-cpp/contrib/zstd/zstd;/par/clickhouse-cpp/contrib/zstd
BINARY_DIR : /par/clickhouse-app/build/third/contrib/zstd/zstd
INTERFACE_INCLUDE_DIRECTORIES : /par/clickhouse-cpp/contrib/zstd
INTERFACE_LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES : PROPERTY-NOTFOUND
LINK_LIBRARIES_ONLY_TARGETS : PROPERTY-NOTFOUND
IMPORTED_LOCATION : PROPERTY-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /par/clickhouse-app/build
root@6ae32a5ffcde:/par/clickhouse-app# cmake --build build -j8
[ 2%] Building CXX object third/contrib/absl/absl/CMakeFiles/absl_int128.dir/numeric/int128.cc.o
[ 3%] Building CXX object third/contrib/cityhash/cityhash/CMakeFiles/cityhash.dir/city.cc.o
[ 3%] Building C object third/contrib/lz4/lz4/CMakeFiles/lz4.dir/lz4.c.o
[ 5%] Building C object third/contrib/lz4/lz4/CMakeFiles/lz4.dir/lz4hc.c.o
[ 6%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/debug.c.o
[ 7%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/entropy_common.c.o
[ 9%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/error_private.c.o
[ 10%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/fse_decompress.c.o
[ 11%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/pool.c.o
[ 12%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/threading.c.o
[ 14%] Linking CXX static library libcityhash.a
[ 15%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/xxhash.c.o
[ 16%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/common/zstd_common.c.o
[ 16%] Built target cityhash
[ 18%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/fse_compress.c.o
[ 19%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/hist.c.o
[ 20%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/huf_compress.c.o
[ 22%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_compress.c.o
[ 23%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_compress_literals.c.o
[ 24%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_compress_sequences.c.o
[ 25%] Linking CXX static library libabsl_int128.a
[ 27%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_compress_superblock.c.o
[ 27%] Built target absl_int128
cityhash::cityhash : /par/clickhouse-app/build/third/contrib/cityhash/cityhash/libcityhash.a
[ 27%] Built target cityhash__cityhash_print_debug_info
[ 28%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_double_fast.c.o
[ 29%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_fast.c.o
[ 31%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_lazy.c.o
[ 32%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_ldm.c.o
[ 33%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstdmt_compress.c.o
[ 35%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/compress/zstd_opt.c.o
[ 36%] Building ASM object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/decompress/huf_decompress_amd64.S.o
[ 38%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/decompress/huf_decompress.c.o
[ 38%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/decompress/zstd_ddict.c.o
[ 40%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/decompress/zstd_decompress_block.c.o
[ 41%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/decompress/zstd_decompress.c.o
[ 42%] Linking C static library liblz4.a
[ 44%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/dictBuilder/cover.c.o
[ 44%] Built target lz4
[ 45%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/dictBuilder/divsufsort.c.o
absl::int128 : /par/clickhouse-app/build/third/contrib/absl/absl/libabsl_int128.a
[ 45%] Built target absl__int128_print_debug_info
lz4::lz4 : /par/clickhouse-app/build/third/contrib/lz4/lz4/liblz4.a
[ 45%] Built target lz4__lz4_print_debug_info
[ 46%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/dictBuilder/fastcover.c.o
[ 48%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/dictBuilder/zdict.c.o
[ 49%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/legacy/zstd_v01.c.o
[ 50%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/legacy/zstd_v02.c.o
[ 51%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/legacy/zstd_v03.c.o
[ 53%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/legacy/zstd_v04.c.o
[ 55%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/legacy/zstd_v05.c.o
[ 55%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/legacy/zstd_v06.c.o
[ 57%] Building C object third/contrib/zstd/zstd/CMakeFiles/zstdstatic.dir/legacy/zstd_v07.c.o
[ 58%] Linking C static library libzstdstatic.a
[ 58%] Built target zstdstatic
zstd::zstd : /par/clickhouse-app/build/third/contrib/zstd/zstd/libzstdstatic.a
[ 58%] Built target zstd__zstd_print_debug_info
[ 59%] Building CXX object third/clickhouse/CMakeFiles/clickhouse-cpp-lib.dir/base/compressed.cpp.o
[ 61%] Building CXX object third/clickhouse/CMakeFiles/clickhouse-cpp-lib.dir/base/input.cpp.o
[ 62%] Building CXX object third/clickhouse/CMakeFiles/clickhouse-cpp-lib.dir/base/output.cpp.o
...
[ 96%] Building CXX object third/clickhouse/CMakeFiles/clickhouse-cpp-lib.dir/query.cpp.o
[ 97%] Linking CXX static library libclickhouse-cpp-lib.a
[ 97%] Built target clickhouse-cpp-lib
[ 98%] Building CXX object CMakeFiles/application-example.dir/app.cpp.o
[100%] Linking CXX executable application-example
[100%] Built target application-example
root@6ae32a5ffcde:/par/clickhouse-app# ./application-example
bash: ./application-example: No such file or directory
root@6ae32a5ffcde:/par/clickhouse-app# build/application-example
1 one
7 seven
1 one
7 seven
root@6ae32a5ffcde:/par/clickhouse-app#
注意分别生成了libzstdstatic.a等静态库文件。而我自己的命令行没有加上它们,所以ld不成功。
最后执行application-example成功写入2行数据,又把它们读出来。
手工把这些静态库文件复制到/par/clickhouse-cpp目录,然后用如下命令行手工编译通过。
root@6ae32a5ffcde:/par/clickhouse-cpp# g++ app.cpp -L /par/clickhouse-cpp/build/clickhouse -L /par/clickhouse-cpp -lclickhouse-cpp-lib -lcityhash -labsl_int128 -llz4 -lzstdstatic -I /par/clickhouse-cpp/ -o app
root@6ae32a5ffcde:/par/clickhouse-cpp# ./app
1 one
7 seven
1 one
7 seven