1.编译环境
- Ubuntu16.4 + arm-hisiv500-linux-
- leveldb 下载地址:https://github.com/google/leveldb/releases
2.移植步骤
修改build_detect_platform文件:
- 添加海思编译工具
if test -z "$CC"; then
CC=gcc
fi
CXX=arm-hisiv500-linux-g++
if test -z "$CXX"; then
CXX=g++
fi
- 修改db/db_iter.h文件
在#endif前添加如下一行
typedef int ssize_t;
如果不定义会出现如下错误:
arm-hisiv500-linux-g++ -I. -I./include -std=c++0x -fno-builtin-memcmp -lpthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT -O2 -DNDEBUG -fPIC -c db/db_iter.cc -o out-shared/db/db_iter.o
db/db_iter.cc:107:3: error: ‘ssize_t’ does not name a type
ssize_t RandomPeriod() {
^
db/db_iter.cc:123:3: error: ‘ssize_t’ does not name a type
ssize_t bytes_counter_;
^
db/db_iter.cc: In constructor ‘leveldb::{anonymous}::DBIter::DBIter(leveldb::DBImpl*, const leveldb::Comparator*, leveldb::Iterator*, leveldb::SequenceNumber, uint32_t)’:
db/db_iter.cc:60:9: error: class ‘leveldb::{anonymous}::DBIter’ does not have any field named ‘bytes_counter_’
bytes_counter_(RandomPeriod()) {
^
db/db_iter.cc:60:37: error: ‘RandomPeriod’ was not declared in this scope
bytes_counter_(RandomPeriod()) {
^
db/db_iter.cc: In member function ‘bool leveldb::{anonymous}::DBIter::ParseKey(leveldb::ParsedInternalKey*)’:
db/db_iter.cc:132:3: error: ‘ssize_t’ was not declared in this scope
ssize_t n = k.size() + iter_->value().size();
^
db/db_iter.cc:133:3: error: ‘bytes_counter_’ was not declared in this scope
bytes_counter_ -= n;
^
db/db_iter.cc:133:21: error: ‘n’ was not declared in this scope
bytes_counter_ -= n;
^
db/db_iter.cc:135:36: error: ‘RandomPeriod’ was not declared in this scope
bytes_counter_ += RandomPeriod();
^
Makefile:415: recipe for target 'out-shared/db/db_iter.o' failed
make: *** [out-shared/db/db_iter.o] Error 1
- 编译:
make
- 编译后生成的库和头文件在如下目录:
out-shared out-static include