按照 https://syslint.com/blog/tutorial/how-to-install-apache-thrift-on-ubuntu-14-04/ 进行,
编译时出现错误
make[4]: Entering directory '/home/lds/mapkeeper/thrift-0.9.3/lib/cpp'
/bin/bash ../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../.. -I../../lib/cpp/src/thrift -I/usr/include -I./src -D__STDC_LIMIT_MACROS -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5 -fPIC -Wall -Wextra -pedantic -g -O2 -std=c++11 -MT src/thrift/qt/libthriftqt5_la-moc__TQTcpServer.lo -MD -MP -MF src/thrift/qt/.deps/libthriftqt5_la-moc__TQTcpServer.Tpo -c -o src/thrift/qt/libthriftqt5_la-moc__TQTcpServer.lo `test -f 'src/thrift/qt/moc__TQTcpServer.cpp' || echo './'`src/thrift/qt/moc__TQTcpServer.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../.. -I../../lib/cpp/src/thrift -I/usr/include -I./src -D__STDC_LIMIT_MACROS -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5 -fPIC -Wall -Wextra -pedantic -g -O2 -std=c++11 -MT src/thrift/qt/libthriftqt5_la-moc__TQTcpServer.lo -MD -MP -MF src/thrift/qt/.deps/libthriftqt5_la-moc__TQTcpServer.Tpo -c src/thrift/qt/moc__TQTcpServer.cpp -fPIC -DPIC -o src/thrift/qt/.libs/libthriftqt5_la-moc__TQTcpServer.o
src/thrift/qt/moc__TQTcpServer.cpp:13:2: error: #error "This file was generated using the moc from 4.8.7. It"
#error "This file was generated using the moc from 4.8.7. It"
^
src/thrift/qt/moc__TQTcpServer.cpp:14:2: error: #error "cannot be used with the include files from this version of Qt."
#error "cannot be used with the include files from this version of Qt."
^
src/thrift/qt/moc__TQTcpServer.cpp:15:2: error: #error "(The moc has changed too much.)"
#error "(The moc has changed too much.)"
^
src/thrift/qt/moc__TQTcpServer.cpp:61:7: error: 'QMetaObjectExtraData' does not name a type
const QMetaObjectExtraData apache::thrift::async::TQTcpServer::staticMetaObjectExtraData = {
^
src/thrift/qt/moc__TQTcpServer.cpp:63:2: warning: extra ';' [-Wpedantic]
};
^
src/thrift/qt/moc__TQTcpServer.cpp:67:57: error: 'staticMetaObjectExtraData' was not declared in this scope
qt_meta_data_apache__thrift__async__TQTcpServer, &staticMetaObjectExtraData }
^
src/thrift/qt/moc__TQTcpServer.cpp: In member function 'virtual const QMetaObject* apache::thrift::async::TQTcpServer::metaObject() const':
src/thrift/qt/moc__TQTcpServer.cpp:76:71: error: conditional expression between distinct pointer types 'QDynamicMetaObjectData*' and 'const QMetaObject*' lacks a cast
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
^
Makefile:1351: recipe for target 'src/thrift/qt/libthriftqt5_la-moc__TQTcpServer.lo' failed
make[4]: *** [src/thrift/qt/libthriftqt5_la-moc__TQTcpServer.lo] Error 1
make[4]: Leaving directory '/home/lds/mapkeeper/thrift-0.9.3/lib/cpp'
Makefile:1574: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/home/lds/mapkeeper/thrift-0.9.3/lib/cpp'
Makefile:538: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/lds/mapkeeper/thrift-0.9.3/lib'
Makefile:609: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/lds/mapkeeper/thrift-0.9.3'
Makefile:530: recipe for target 'all' failed
make: *** [all] Error 2
后来下载了thrift 10 ,还是这样
经过查找确认,是qt版本的问题,qt4是默认的版本,根据qt官网介绍装好qt5以后,仍然是这错误。继续确认,使用qmake -v 发现qt还是4的版本。卸载qt4后,运行qmake 出现错误。根据 https://stackoverflow.com/questions/39735998/make-qmake-use-qt5-by-default, 使用 export QT_SELECT=5 ,发现 qmake -v变为5的版本了。在thrift目录make clean,./configure, make
qt的错误没有了。
然后编译成功。 但是发现 thrift可以直接通过apt-install 安装。
也许ubuntu默认就带了thrift 0.9
2017.8.24
(1)按照 http://blog.csdn.net/szyjsj/article/details/69567757 下载thrift 0.8,安装时出现
rake abort!
LoadError: cannot load such file -- spec/rake/spectask
错误。
(2) 使用apt-get 安装,安装的是thrift 0.9.1 ,安装成功后,/usr/local/include/thrift 下没有 Thrift.h ,具体就是 /usr/local/include/thrift 下没有。 进入mapkeeper 的thrift目录make时就会出现
apkeeper_types.h:10:27: fatal error: thrift/Thrift.h: No such file or directory
错误。
(3) 按照 https://stackoverflow.com/questions/38077740/error-no-such-file-or-directory-occurs-when-using-thrift-c-to-connect-hbase 下载0.9.2,成功编译,成功安装。
而且此时,/usr/local/include/thrift 有 Thrift.h 了。
进入mapkeeper的thrift目录,运行make,没有报找不到文件错误了。
gen-cpp貌似成功了,里面多了很多新文件,
lds@DL:~/mapkeeper/mapkeeper/thrift$ ls *cpp
libmapkeeper.a Makefile mapkeeper_constants.h MapKeeper.cpp MapKeeper.o mapkeeper_types.cpp mapkeeper_types.o
libmapkeeper.so mapkeeper_constants.cpp mapkeeper_constants.o MapKeeper.h MapKeeper_server.skeleton.cpp mapkeeper_types.h
但是gen-java在下载了很多文件后出错了。全是找不到符号错误。
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/lds/mapkeeper/mapkeeper/thrift/gen-java/target/generated-sources/thrift/com/yahoo/mapkeeper/MapKeeper.java:[1124,84] error: cannot find symbol
[ERROR] package org.apache.thrift
(4) 再次根据 http://blog.csdn.net/szyjsj/article/details/69567757 中对java进行安装,
- sudo add-apt-repository ppa:webupd8team/java
- sudo apt-get update
sudo apt-get install oracle-java7-installer
发现oracle-java7-installer 无法下载,然后尝试oracle-java8-installer,下载了很多,但是最后不知道为什么又自动进行7的安装而且失败。但是貌似8已经安装好了,
lds@DL:~$ ls /usr/lib/jvm/
default-java java-1.8.0-openjdk-amd64 java-7-oracle java-8-openjdk-amd64 java-8-oracle
然后按照8安装结束的提示 运行了 sudo apt install oracle-java8-set-default
然后发现 $JAVA_HOME 已经被全局设置为了 /usr/lib/jvm/java-8-oracle
最后,再次去mapkeeper的thrift目录下运行make,然而,结果还是那样。
(5) 我认为leveldb用不到java,于是就不管了,直接去leveldb目录下,按照https://github.com/m1ch1/mapkeeper/tree/master/leveldb, 将leveldb的相关文件拷贝到了系统路径下。我认为boost肯定已经安装了(经验证,boost版本是1_58)。
运行make后,出现 错误
/usr/bin/ld: /tmp/ccXW9tJO.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
//usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
根据 https://github.com/uzh-rpg/rpg_svo/issues/19 添加了
-lboost_system 后,又出现 /usr/bin/ld: /usr/local/lib/libleveldb.a(port_posix.o): undefined reference to symbol 'pthread_once@@GLIBC_2.2.5'
按照 https://www.linuxquestions.org/questions/linux-software-2/undefined-reference-to-symbol-%27pthread_once%40%40glibc_2-2-5%27-4175421447/,添加了
-L/lib64 -lpthread
说“durations” 未定义,这个好解决,因为这是我在db_bench里定义的。解决办法是使用原版的leveldb。
但是又说
/usr/local/lib/libleveldb.a(table_builder.o): In function `leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder*, leveldb::BlockHandle*)':
table_builder.cc:(.text+0x7a9): undefined reference to `snappy::MaxCompressedLength(unsigned long)'
table_builder.cc:(.text+0x7d6): undefined reference to `snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)'
/usr/local/lib/libleveldb.a(format.o): In function `leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*)':
format.cc:(.text+0x43a): undefined reference to `snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)'
format.cc:(.text+0x5c0): undefined reference to `snappy::RawUncompress(char const*, unsigned long, char*)'
好吧,明天再看。
2017.8.25
(1) 继续上面的(5),使用最新版的leveldb,仍然有此问题。
按照 https://github.com/freeminer/freeminer/pull/41/files 装了这些包,仍然有此问题。事实上 libsnappy-dev 包已经存在了。
按照 https://github.com/0x00A/ldb/issues/48 添加-lsnappy 不能解决,remove libsnappy-dev 也不能解决。
很多地方都认为是 libsnappy 没有被连接,有一个csdn的帖子用的是federa,他用yum装了 libsnappy-dev 然后 -lsnappy 就解决了,但是在ubuntu下貌似行,另外上面的连接里还有人说ubuntu14不需要装 libsnappy-dev,但是我remove后make的错误明显表明 libsnappy-dev没有安装。
但是有一个关键的发现:(a)如果移除 libsnappy-dev,出现正常错误,即undefined reference;(2)移除 libsnappy-dev后,Makefile里加上 -lsnappy,则出现 /usr/bin/ld: cannot find -lsnappy;(c)装上 libsnappy-dev,加上 -lsnappy,出现正常错误,即undefined reference。
从(c)和(b)似乎可以看出, -lsnappy是被链接了的,但是链接上的snappy似乎没有定义MaxCompressedLength这些变量。