[opensuse-packaging] [Q] Build failure -- undefined reference to clock_gettime
![](https://seccdn.libravatar.org/avatar/25409df37029844e753620cd7a46a63d.jpg?s=120&d=mm&r=g)
Hi, I'm getting the following build failure, but only for openSUSE_11.2 (both i586 and x86_64): On Sunday 02 May 2010 14:42:31 hermes@opensuse.org wrote:
Package patch (version 2.6.1.64-7.1) of project devel:tools failed to build for openSUSE_11.2 / i586.
Review the build log: osc remotebuildlog devel:tools patch openSUSE_11.2 i586 | less
From the build log: checking for library containing clock_gettime... -lrt checking for clock_gettime... yes checking for clock_settime... yes [...] gcc -std=gnu99 -fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -Wall -O2 -pipe -lrt -o patch inp.o patch.o pch.o util.o version.o merge.o ../lib/libpatch.a patch.o: In function `make_temp': patch.c:(.text+0x459): warning: the use of `mktemp' is dangerous, better use `mkstemp' ../lib/libpatch.a(gettime.o): In function `gettime': gettime.c:(.text+0x14): undefined reference to `clock_gettime' collect2: ld returned 1 exit status The clock_gettime link error is weird: this function should be provided by librt, which is being linked against. Any ideas? Thanks, Andreas -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
![](https://seccdn.libravatar.org/avatar/0006bf0ff51653f0a31c4a5ae55d3b0d.jpg?s=120&d=mm&r=g)
2010/5/2 Andreas Gruenbacher <agruen@suse.de>:
Hi,
I'm getting the following build failure, but only for openSUSE_11.2 (both i586 and x86_64):
On Sunday 02 May 2010 14:42:31 hermes@opensuse.org wrote:
Package patch (version 2.6.1.64-7.1) of project devel:tools failed to build for openSUSE_11.2 / i586.
Review the build log: osc remotebuildlog devel:tools patch openSUSE_11.2 i586 | less
From the build log:
checking for library containing clock_gettime... -lrt checking for clock_gettime... yes checking for clock_settime... yes [...] gcc -std=gnu99 -fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -Wall -O2 -pipe -lrt -o patch inp.o patch.o pch.o util.o version.o merge.o ../lib/libpatch.a patch.o: In function `make_temp': patch.c:(.text+0x459): warning: the use of `mktemp' is dangerous, better use `mkstemp' ../lib/libpatch.a(gettime.o): In function `gettime': gettime.c:(.text+0x14): undefined reference to `clock_gettime' collect2: ld returned 1 exit status
The clock_gettime link error is weird: this function should be provided by librt, which is being linked against.
Any ideas?
From ld man "-l namespec" description: "The linker will search an archive only once, at the location where it is specified on the command line. If the archive defines a symbol which was undefined in some object which appeared before the archive on the com- mand line, the linker will include the appropriate file(s) from the archive. However, an undefined symbol in an object appearing later on the command line will not cause the linker to search the archive again."
Since ../lib/libpatch.a is after -lrt he symbol isn't searched again in librt. This happens only since openSUSE 11.2 because the behavior seems to be forced only when using the --as-needed ld option. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
![](https://seccdn.libravatar.org/avatar/25409df37029844e753620cd7a46a63d.jpg?s=120&d=mm&r=g)
On Sunday 02 May 2010 15:31:51 Cristian Morales Vega wrote:
Since ../lib/libpatch.a is after -lrt he symbol isn't searched again in librt. This happens only since openSUSE 11.2 because the behavior seems to be forced only when using the --as-needed ld option.
Thanks, this seems to have helped. Andreas -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
participants (2)
-
Andreas Gruenbacher
-
Cristian Morales Vega