Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8139056
  • 博文数量: 594
  • 博客积分: 13065
  • 博客等级: 上将
  • 技术积分: 10324
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-26 16:44
个人简介

推荐: blog.csdn.net/aquester https://github.com/eyjian https://www.cnblogs.com/aquester http://blog.chinaunix.net/uid/20682147.html

文章分类

全部博文(594)

分类: LINUX

2015-08-21 15:07:54

问题版本:0.9.0
make[4]: Entering directory `/tmp/X/thrift-0.9.0/lib/cpp'
/bin/sh ../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../..  -I/usr/local/thirdparty/boost/include -I./src -I./src/thrift -I/usr/local/thirdparty/openssl/include -Wall -g -O2 -MT Thrift.lo -MD -MP -MF .deps/Thrift.Tpo -c -o Thrift.lo `test -f 'src/thrift/Thrift.cpp' || echo './'`src/thrift/Thrift.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../.. -I/usr/local/thirdparty/boost/include -I./src -I./src/thrift -I/usr/local/thirdparty/openssl/include -Wall -g -O2 -MT Thrift.lo -MD -MP -MF .deps/Thrift.Tpo -c src/thrift/Thrift.cpp  -fPIC -DPIC -o .libs/Thrift.o
In file included from src/thrift/Thrift.cpp:22:
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/cstdlib:119: error: '::malloc' has not been declared
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/cstdlib:127: error: '::realloc' has not been declared
src/thrift/Thrift.cpp: In member function 'void apache::thrift::TOutput::printf(const char*, ...)':
src/thrift/Thrift.cpp:46: error: 'malloc' was not declared in this scope
make[4]: *** [Thrift.lo] Error 1


解决方法:
在成功执行configure后(在未执行configure之前找不到下列两行),修改与configure同目录下的config.h文件,将文件中的如下两行注释掉:
#define malloc rpl_malloc
#define realloc rpl_realloc


附1:安装Thrift命令行:
./configure --prefix=/usr/local/thirdparty/thrift-0.9.0 --with-boost=/usr/local/thirdparty/boost --with-libevent=/usr/local/thirdparty/libevent CPPFLAGS="-I/usr/local/thirdparty/openssl/include" LDFLAGS="-ldl -L/usr/local/thirdparty/openssl/lib" --with-qt4=no --with-c_glib=no --with-csharp=no --with-erlang=no --with-perl=no --with-ruby=no --with-haskell=no --with-go=no --with-d
当OpenSSL未以默认安装目录时,请注意上面的用法。


附2:相关博文:
(安装thrift时,注意openssl参数)http://blog.chinaunix.net/uid-20682147-id-3399150.html


如果在使用Thrift时,编译遇到类似“TTransport.h:107: error: 'uint32_t' does not name a type”的错误,只需要在Thrift.h文件中增加一行:#include
Thrift.h文件位于make install后的include目录下,如果不知道在哪,可以使用find命令查找。


阅读(5026) | 评论(3) | 转发(0) |
给主人留下些什么吧!~~

Aquester2017-08-17 16:01:34

thrift-0.9.3编译和0.9.0稍不同,标准方式指定openssl:
./configure --prefix=/usr/local/thrift-0.9.3 CPPFLAGS=\"-fPIC\" LDFLAGS=\"-fPIC\" --with-libevent=/usr/local/libevent --with-boost=/usr/local/boost --with-openssl=/usr/local/openssl --enable-tutorial=no --enable-tests=no --enable-coverage=no --with-cpp=yes --with-java=yes --with-php=yes --with-ruby=no --with-python=no --with-erlang=no --with-csharp=no --with-qt4=no --with-qt5=no --with-c_glib=no --with-perl=no --with-haskell=no

Aquester2017-08-17 13:14:43

./configure --prefix=/usr/local/thirdparty/thrift-0.9.3 --with-libevent=/usr/local/thirdparty/libevent --with-boost=/usr/local/thirdparty/boost CXXFLAGS=\"-I/usr/local/thirdparty/openssl/include\" LDFLAGS=\"-L/usr/local/thirdparty/openssl/lib\" --with-ruby=no --with-python=no --with-erlang=no --with-csharp=no --with-qt4=no --with-qt5=no --with-c_glib=no --with-perl=no --with-haskell=no --with-d=no --with-go=no --with-nodejs=no --with-haxe=no

Aquester2017-02-08 14:28:16

64位机器上编译,遇到如下链接错误,依赖的thrift为thrift-0.9.0:
/bin/ld: /usr/local/thrift/lib/libthrift.a(Thrift.o): relocation R_X86_64_32S against `_ZNSs4_Rep20_S_empty_rep_storageE\' can not be used when making a shared object; recompile with -fPIC
/usr/local/thrift/lib/libthrift.a: could not read symbols: 错误的值

解决办法:设置CXXFLAGS,加上-fPIC,重编译thrift,但注意不能是CPPFLAGS,如下所示
 ./configure --prefix=/usr/local/thrift-0.9.0 --with-boost=/usr/local/boost --with-libevent=/us