我尝试在 ubuntu precise32 上用 thrift 0.9.0 编译一个 cpp 应用程序:
g++ hello_client.cpp gen-cpp/HelloSvc.cpp -lthrift
但是,这会导致:
In file included from /usr/local/include/thrift/transport/TSocket.h:25:0,
from hello_client.cpp:4:
/usr/local/include/thrift/transport/TTransport.h:34:1: error: 'uint32_t' does not name a type
/usr/local/include/thrift/transport/TTransport.h:107:3: error: 'uint32_t' does not name a type
...
最佳答案
我尝试通过以下方式修复 0.9.0:
1) 安装 python-dev (我注意到一个错误: missing python.h when building thrift)
sudo apt-get install python-dev
2) Thrift :
./configure CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H"
仍然是同样的错误,所以我决定检查、构建和安装最新的 thrift(git 中的 HEAD 版本 6f2a5037105ccad05eb84ec0a60da3389c85eb3f)。
使用最新的 thrift,构建 cpp 客户端没有错误。但是,运行 a.out
返回错误:
./a.out: error while loading shared libraries: libthrift-1.0.0-dev.so: cannot open
shared object file: No such file or directory
将 LD_LIBRARY_PATH 设置为新建的 thrift 库修复了这个问题:
导出 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$THRIFT_SRC/lib/cpp/.libs/
关于c++ - 问题编译 thrift 0.9.0 c++ 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17551531/