Why do I get a TimePoint2TimeSpec linker error

363 views
Skip to first unread message

Okke Hendriks

unread,
Sep 20, 2016, 8:11:43 AM9/20/16
to grpc.io

In function `grpc::TimePoint<std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > >::TimePoint(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&)':
prototype_a.cpp:(.text._ZN4grpc9TimePointINSt6chrono10time_pointINS1_3_V212system_clockENS1_8durationIlSt5ratioILl1ELl1000000000EEEEEEEC2ERKS9_[_ZN4grpc9TimePointINSt6chrono10time_pointINS1_3_V212system_clockENS1_8durationIlSt5ratioILl1ELl1000000000EEEEEEEC5ERKS9_]+0x1f): undefined reference to `
grpc::Timepoint2Timespec(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&, gpr_timespec*)'
collect2: error: ld returned 1 exit status

I am getting the above linker error when adding the following lines to my 'procom' library.

std::chrono::system_clock::time_point deadline(std::chrono::system_clock::now() + std::chrono::seconds(10));
_channel->WaitForConnected(deadline);

I am linking 'procom' with the following CMake commands:

add_library(procom SHARED src/procom.cpp)
target_link_libraries
(procom pthread ${ZLIB_LIBRARIES} libgpr.a libgrpc++_unsecure.a libgrpc_unsecure.a libprotobuf.a)

Which I am using later on in a 'prototype_a' application, which is being build with the following CMake commands:

add_executable(proto_a src/prototype/prototype_a.cpp)
target_link_libraries(proto_a procom)

I would appreciate it very much if someone has an idea of what I am doing wrong? :)
Thank you in advance!

Masood Malekghassemi

unread,
Sep 27, 2016, 7:41:41 PM9/27/16
to grpc.io
Unfortunately our CMake support is still 'experimental'. If you do find specifically what's breaking for you and file a bug on whatever flags are missing wherever and such, we'd appreciate it! Until we're past 'experimental' support, all I can suggest is to use vanilla make or to dig deep: like checking the symbols in the compiled object files, maybe see if anything's missing from them, look through #defines and see if your system isn't getting properly autoconfigured for by the preprocessor at compilation time, or even files containing the missing symbols themselves missing from commands spat out during a verbose build process. We'd like to know what's gone wrong as well.

sumit...@gmail.com

unread,
Mar 5, 2018, 5:52:59 AM3/5/18
to grpc.io
I am facing the same linker error:

undefined reference to `grpc::Timepoint2Timespec(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&, gpr_timespec*)'
collect2: error: ld returned 1 exit status

Previously it was working fine when my code was on following version of Linux:

Linux 2.6.32-504.63.3.el6.x86_64

Then I moved my code to another machine, where I started facing the linker error. Linux version of new machine:

Linux 3.10.0-514.26.2.el7.x86_64

Any idea if there is any difference in behavior of CMake on these 2 versions of Linux?
Thank you in advance!!
Reply all
Reply to author
Forward
0 new messages