FreeBSDへ最新Google LevelDBのインストール
> gmake Makefile:16: *** missing separator. Stop.
ああ,こんなスクリプトが入ったのね...
# detect what platform we're building on $(shell sh ./build_detect_platform)
この」build_detect_platformスクリプトに,FreeBSD用のコードも加えました.
FreeBSD) PLATFORM=OS_FREEBSD echo "PLATFORM_CFLAGS=-pthread -DOS_FREEBSD" >> build_config.mk echo "PLATFORM_LDFLAGS=-lpthread" >> build_config.mk
gmakeするとエラーが...
g++45 -c -I. -I./include -fno-builtin-memcmp -DLEVELDB_PLATFORM_POSIX -pthread -DOS_FREEBSD -O2 -DNDEBUG db/db_impl.cc -o db/db_impl.o In file included from db/db_impl.cc:5:0: ./db/db_impl.h:121:3: error: 'AtomicPointer' in namespace 'leveldb::port' does not name a type
AtomicPointerを定義しているport/atomic_pointer.hがincludeされていなかったので,db/db_impl.hに行を追加しました.
(なんでこんなコードがコミットされてるんや...)
#include "port/atomic_pointer.h"
再びgmakeすると,似たエラー...
g++45 -c -I. -I./include -fno-builtin-memcmp -DLEVELDB_PLATFORM_POSIX -pthread -DOS_FREEBSD -O2 -DNDEBUG db/memtable.cc -o db/memtable.o In file included from ./db/memtable.h:11:0, from db/memtable.cc:5: ./db/skiplist.h:105:3: error: 'AtomicPointer' in namespace 'leveldb::port' does not name a type
また同じく,インクルードを追加.
#include "port/port.h" #include "port/atomic_pointer.h" // ここを追加 #include "util/arena.h"
できた!
ar -rs libleveldb.a ./db/builder.o ./db/db_impl.o ./db/db_iter.o ./db/filename.o ./db/dbformat.o ./db/log_reader.o ./db/log_writer.o ./db/memtable.o ./db/repair.o ./db/table_cache.o ./db/version_edit.o ./db/version_set.o ./db/write_batch.o ./port/port_posix.o ./table/block.o ./table/block_builder.o ./table/format.o ./table/iterator.o ./table/merger.o ./table/table.o ./table/table_builder.o ./table/two_level_iterator.o ./util/arena.o ./util/cache.o ./util/coding.o ./util/comparator.o ./util/crc32c.o ./util/env.o ./util/env_posix.o ./util/hash.o ./util/histogram.o ./util/logging.o ./util/options.o ./util/status.o ar: warning: creating libleveldb.a
テスト...
> env LD_LIBRARY_PATH=/usr/local/lib/gcc45/ ./db_test ==== Test DBTest.Empty ==== Test DBTest.ReadWrite ==== Test DBTest.PutDeleteGet ==== Test DBTest.IterEmpty ==== Test DBTest.IterSingle ==== Test DBTest.IterMulti ==== Test DBTest.IterSmallAndLargeMix ==== Test DBTest.Recover ==== Test DBTest.RecoveryWithEmptyLog ==== Test DBTest.MinorCompactionsHappen ==== Test DBTest.RecoverWithLargeLog ==== Test DBTest.CompactionsGenerateMultipleFiles (中略) 2705 entries compared: ok=1 ==== PASSED 24 tests
OK!