youzan / ZanRedisDB

Yet another distributed fault-tolerant key-value database Compatible with Redis written in Golang.
MIT License
388 stars 60 forks source link

按照文档编译,RocksDB 编译失败 #82

Closed HalfStackDeveloper closed 3 years ago

HalfStackDeveloper commented 3 years ago

PORTABLE=1 USE_SSE=1 USE_PCLMUL=1 WITH_JEMALLOC_FLAG=1 JEMALLOC=1 make static_lib

$DEBUG_LEVEL is 0 GEN util/build_version.cc $DEBUG_LEVEL is 0 GEN util/build_version.cc CC cache/clock_cache.o CC cache/lru_cache.o CC cache/sharded_cache.o CC db/builder.o In file included from db/builder.cc:16: In file included from ./db/compaction/compaction_iterator.h:13: In file included from ./db/compaction/compaction.h:11: In file included from ./db/version_set.h:31: In file included from ./db/column_family.h:18: In file included from ./db/table_cache.h:25: In file included from ./table/table_reader.h:14: ./table/get_context.h:91:3: error: explicitly defaulted default constructor is implicitly deleted [-Werror,-Wdefaulted-function-deleted] GetContext() = default; ^ ./table/get_context.h:168:18: note: default constructor of 'GetContext' is implicitly deleted because field 'tracing_getid' of const-qualified type 'const uint64_t' (aka 'const unsigned long long') would not be initialized const uint64_t tracing_getid; ^ In file included from db/builder.cc:19: ./db/internal_stats.h:112:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_BYTES, ^ ./include/rocksdb/statistics.h:196:3: note: previous declaration is here WAL_FILE_BYTES, // Number of bytes written to WAL ^ In file included from db/builder.cc:19: ./db/internal_stats.h:113:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_SYNCED, ^ ./include/rocksdb/statistics.h:195:3: note: previous declaration is here WAL_FILE_SYNCED, // Number of times WAL sync is done ^ In file included from db/builder.cc:19: ./db/internal_stats.h:114:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] BYTES_WRITTEN, ^ ./include/rocksdb/statistics.h:131:3: note: previous declaration is here BYTES_WRITTEN, ^ In file included from db/builder.cc:19: ./db/internal_stats.h:115:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] NUMBER_KEYS_WRITTEN, ^ ./include/rocksdb/statistics.h:124:3: note: previous declaration is here NUMBER_KEYS_WRITTEN, ^ In file included from db/builder.cc:19: ./db/internal_stats.h:116:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_OTHER, ^ ./include/rocksdb/statistics.h:201:3: note: previous declaration is here WRITE_DONE_BY_OTHER, // Equivalent to writes done for others ^ In file included from db/builder.cc:19: ./db/internal_stats.h:117:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_SELF, ^ ./include/rocksdb/statistics.h:200:3: note: previous declaration is here WRITE_DONE_BY_SELF, ^ In file included from db/builder.cc:19: ./db/internal_stats.h:118:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_WITH_WAL, ^ ./include/rocksdb/statistics.h:203:3: note: previous declaration is here WRITE_WITH_WAL, // Number of Write calls that request WAL ^ 8 errors generated. make: *** [db/builder.o] Error 1

HalfStackDeveloper commented 3 years ago

已解决。https://blog.csdn.net/bao05673/article/details/101653332

HalfStackDeveloper commented 3 years ago

编译的时候可以加上标签 -Wno-error= 让包含特定信息的错误强行不报错。

更改 /rocksdb/CMakeLists.txt 文件,diff 形式(如果是 CockroachDB 的工程,该文件在 /cockroach/c-deps/ 文件夹下):

option(FAIL_ON_WARNINGS "Treat compile warnings as errors" ON) if(FAIL_ON_WARNINGS) if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") else() # assume GCC

修改 /rocksdb/Makefile 文件:

ifndef DISABLE_WARNING_AS_ERROR