Why can't linker find gettimeofday?
Posted: Fri Aug 01, 2014 9:11 am
I'm trying to add UnitTest++ to an existing project in NBEclipse 2.5.3, and the library builds successfully from source. However the existing project fails to link with these errors:
The compiler didn't seem to have a problem picking up the forward declaration from sys/time.h. The definition appears to be in the C standard library:
I even tried explicitly including libc.a in the linker libraries page under Settings in my project properties - which seems unnecessary, but I can't figure out why ld can't find that function. All the pieces seem to be in place. I've seen a couple somewhat-related posts but nobody seems to have an answer.
Thanks
Code: Select all
C:\Foo\UnitTest++\libUnitTest++.a(TimeHelpers.o): In function `UnitTest::Timer::GetTimeInMs() const':
C:\Foo\UnitTest++/src/Bar/TimeHelpers.cpp:23: undefined reference to `gettimeofday'
C:\Foo\UnitTest++\libUnitTest++.a(TimeHelpers.o): In function `UnitTest::Timer::Start()':
C:\Foo\UnitTest++/src/Bar/TimeHelpers.cpp:16: undefined reference to `gettimeofday'
collect2: ld returned 1 exit status
Code: Select all
nburn/gcc-m68k/m68k-elf/lib $ nm libc.a | grep gettime
lib_a-gettimeofday.o:
00000000 T _gettimeofday_r
U gettimeofday
U _gettimeofday_r
Thanks