LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-07-2005, 12:15 AM   #1
santhosh.linux
Member
 
Registered: Nov 2005
Location: India
Posts: 42

Rep: Reputation: 15
time.h file include,compilation problem


Hai friends,

when i include time.h file(/usr/include/time.h),in my program at compilation time i am getting following messages(errors)

I am expecting solution from u


/tmp/cc61O7TY.o(.text+0x10): In function `wait_code':
: undefined reference to `clock_gettime'
/tmp/cc61O7TY.o(.text+0x24): In function `wait_code':
: undefined reference to `timespec_add_ns'
/tmp/cc61O7TY.o(.text+0x36): In function `wait_code':
: undefined reference to `clock_nanosleep'
/tmp/cc61O7TY.o(.text+0x81): In function `wait_code':
: undefined reference to `clock_gettime'
/tmp/cc61O7TY.o(.text+0xa0): In function `wait_code':
: undefined reference to `timespec_add_ns'
/tmp/cc61O7TY.o(.text+0xb2): In function `wait_code':
: undefined reference to `clock_nanosleep'
/tmp/cc61O7TY.o(.text+0x132): In function `lock_code':
: undefined reference to `clock_gettime'
/tmp/cc61O7TY.o(.text+0x151): In function `lock_code':
: undefined reference to `timespec_add_ns'
/tmp/cc61O7TY.o(.text+0x163): In function `lock_code':
: undefined reference to `clock_nanosleep'
/tmp/cc61O7TY.o(.text+0x209): In function `main':
: undefined reference to `rtl_main_wait'
collect2: ld returned 1 exit status


please reply with answer if u know,

thanks and regards,
santhosh.linux@gmail.com
 
Old 12-07-2005, 12:07 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Those are usually defined in #include <sys/time.h> -- normally #include <time.h>
will also find this file

If you have some #define statments elsewhere you may be turning off some of the header files. Read your /usr/include/time.h and see why this is happening.
There are some versions of Linux that require certain #include <xxx> be listed before others, otherwise this can happen. See Marc Rochkind's 'Advanced Unix Programming' for more on this problem.
 
Old 01-03-2008, 12:42 PM   #3
vxir
LQ Newbie
 
Registered: Oct 2003
Posts: 1

Rep: Reputation: 0
those are linker errors.

use "-lrt" to resolve them... (I tried on ubuntu 6.10)
 
Old 03-17-2008, 09:15 PM   #4
wangr198
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
Thanks!vxir is right
 
Old 10-31-2009, 12:56 PM   #5
David McCracken
LQ Newbie
 
Registered: Oct 2009
Location: Silicon Valley
Distribution: Fedora 10 and 11
Posts: 5

Rep: Reputation: 0
I know this is a pretty old thread but the -lrt fix is still correct and needed. I just used it for the same problem in Fedora 11. Even the most recent man pages do not mention this library requirement.
 
Old 10-31-2009, 02:49 PM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
The man-pages for what?
Whenever you include a header, you also have to tell the linker to link to the referenced library which the header is for.
 
Old 11-01-2009, 03:47 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
That's the confusing part for many people; you do not always have to do it.
 
Old 11-01-2009, 09:43 AM   #8
David McCracken
LQ Newbie
 
Registered: Oct 2009
Location: Silicon Valley
Distribution: Fedora 10 and 11
Posts: 5

Rep: Reputation: 0
For example, the man page for clock_gettime. Regarding library inclusion based on header names, even if one were sure that a library were needed, the name of that library would not necessarily be obvious from the name of the header file. How would one deduce the library name rt from the header name time.h?
 
Old 12-21-2009, 05:36 AM   #9
shariefbe
Member
 
Registered: Aug 2008
Location: Tiruchirappalli, India
Distribution: UBUNTU 11.04
Posts: 368

Rep: Reputation: 31
hello can anyone tell me how to solve this problem

Code:
/Desktop/qt-everywhere-opensource-src-4.6.0/lib -lQtWebKit -L/home/ariem/Desktop/qt-everywhere-opensource-src-4.6.0/lib -lQtGui -lQtNetwork -lQtCore -lpthread 
/home/ariem/Desktop/qt-everywhere-opensource-src-4.6.0/lib/libQtCore.so: undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make: *** [browser] Error 1
root@ariem-desktop:/home/ariem/Desktop/qt-everywhere-opensource-src-4.6.0/demos/browser# -lrt
bash: -lrt: command not found
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar.gz file did not include install file |Spec-ops Linux - Newbie 12 11-17-2005 08:25 AM
QT3 compilation time theYinYeti Linux - Software 2 05-04-2005 03:17 AM
FIle include problem (regarding routing table) rajesh_b Programming 3 10-18-2004 11:37 PM
gentoo compilation time andrewlkho Linux - Distributions 3 07-04-2003 06:05 AM
compilation time chrisb Programming 2 05-08-2001 07:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration