编译thrift 0.9.1 cpp代码时遇到问题。
我的makefile是这样的:
objects = genFeaVec_multiThread_HSV.o imgIDservice_types.o ImgIDdifNameService.o
genFeaVec_multiThread_HSV_thrift : $(objects)
g++ -o genFeaVec_multiThread_HSV_thrift $(objects) -I/usr/include -L/usr/lib64 -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_video -lopencv_imgproc -lopencv_core -lthrift
编译器g ++告诉:
g++ -o genFeaVec_multiThread_HSV_thrift genFeaVec_multiThread_HSV.o imgIDservice_types.o ImgIDdifNameService.o -I/usr/include -L/usr/lib64 -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_video -lopencv_imgproc -lopencv_core -I/usr/include/ -L/usr/lib64 -lthrift -lthriftnb -levent
undefined reference to `apache::thrift::transport::TSocket::TSocket(std::string const&, int)'
我的cpp代码是这样的:
std::string host_i=string("localhost");
boost::shared_ptr<TTransport> socket(new TSocket(host_i,9537));
我尝试过host_i.c_str()和&#34; localhost&#34;但它不起作用。 我检查了lib -lthrift:
nm -CD /usr/lib64/libthrift-0.9.1.so | grep TSocket
`00000000000670f0 T apache::thrift::transport::TSocket::TSocket(int)
0000000000066ea0 T apache::thrift::transport::TSocket::TSocket(std::string)
0000000000066d80 T apache::thrift::transport::TSocket::TSocket(std::string, int)
0000000000066fc0 T apache::thrift::transport::TSocket::TSocket()
00000000000670f0 T apache::thrift::transport::TSocket::TSocket(int)
0000000000066ea0 T apache::thrift::transport::TSocket::TSocket(std::string)
0000000000066d80 T apache::thrift::transport::TSocket::TSocket(std::string, int)`
包含文件没问题。
在目的地/usr/include
我认为问题仍然是如何导入lib。 但我不知道我的makefile有什么问题。
答案 0 :(得分:0)
尝试使用其他库:stdlib libc++
,而不是libstdc++
和-lthrift
。