Need help with C++ linker error


(Xuhui Sun) #1

I am currently using libtorch c++ develop a classification server, however, I am encountering some problem at compiler linking stage.

There are some linking errors when I link libtorch together with glog and thrift.
google glog / gflags:

main.cpp:(.text+0x17b): undefined reference to `fLS::FLAGS_log_dir'

apache thrift:

Service.cpp:(.text+0x1d5e): undefined reference to `apache::thrift::async::TConcurrentClientSyncInfo::getPending(std::string&, apache::thrift::protocol::TMessageType&, int&)'
Service.cpp:(.text+0x20b4): undefined reference to `apache::thrift::async::TConcurrentClientSyncInfo::updatePending(std::string const&, apache::thrift::protocol::TMessageType, int)'

Also, there is no such linking error if I compile my code without find torch library in my CMake file, and my application could build successfully.

I don’t know if this is related to my CMake file settings or this is a bug in the current library. By the way, I am linking with Pytorch stable(1.0) Linux C++ LibTorch with CUDA9.0 support. Also thrift 0.9.3, glog-0.3.5 build from source.

Thanks in advance.


(Xuhui Sun) #2

In case anyone has a similar issue, build the lib from source solve the problem.
Also please check this for detail.