我按照指南做了:
brew install rocksdb
我被困在这里。我该怎么做才能使用rocksdb
?
我复制了这个示例文件的内容并尝试在 Mac OS 上使用gcc-5
(brew) 和(clang) 编译它,但它们都返回错误。gcc
我在 Mac OS 10.11.5 上使用 Xcode 7.3.1。
错误是:
Undefined symbols for architecture x86_64:
"_rocksdb_backup_engine_close", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_backup_engine_create_new_backup", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_backup_engine_open", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_backup_engine_restore_db_from_latest_backup", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_close", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_get", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_open", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_options_create", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_options_destroy", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_options_increase_parallelism", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_options_optimize_level_style_compaction", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_options_set_create_if_missing", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_put", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_readoptions_create", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_readoptions_destroy", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_restore_options_create", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_restore_options_destroy", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_writeoptions_create", referenced from:
_main in ccNZ2cWh.o
"_rocksdb_writeoptions_destroy", referenced from:
_main in ccNZ2cWh.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
更新:
将rocksdb库添加到Xcode中的Header和Library Search Path之后,如下所示:
rocksdb::DB* db;
rocksdb::Options options;
并遇到了另一个问题: