Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-12-2013, 05:20 PM   #1
LQ Newbie
Registered: Jul 2013
Posts: 2

Rep: Reputation: Disabled


I've tried to compile the example program from timer_create man page and it failed. Could anyone help me?

Attached Files
File Type: txt timer_create.txt (3.3 KB, 99 views)

Last edited by wieczoj; 07-12-2013 at 05:43 PM.
Old 07-12-2013, 05:22 PM   #2
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Can you provide more detail on teh code you are trying to compile. Place it inside teh code tags on your post will be a big help. I looked at the man page i have installed for timer_create and got good info on what it is but there were no example scripts listed.
Old 07-13-2013, 04:02 AM   #3
Senior Member
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 273Reputation: 273Reputation: 273
Hi and welcome to LQ!
You didn't post the error but i suppose that you used gcc without "rt" library.

Try this:

gcc -lrt time_create.c
It should work.
1 members found this post helpful.
Old 07-13-2013, 04:32 AM   #4
LQ Newbie
Registered: Jul 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
gcc -c timer_create.c
echo $?
gcc -lrt timer_create.c
/tmp/ccF6L5We.o: In function `print_siginfo':
timer_create.c.text+0x5f): undefined reference to `timer_getoverrun'
/tmp/ccF6L5We.o: In function `main':
timer_create.c.text+0x245): undefined reference to `timer_create'
timer_create.c.text+0x326): undefined reference to `timer_settime'
collect2: ld returned 1 exit status
Old 07-13-2013, 05:49 AM   #5
Senior Member
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 273Reputation: 273Reputation: 273
Works for me:

$> gcc timer_create.c 
/tmp/ccY0iuGU.o: In function `print_siginfo':
timer_create.c:(.text+0x43): undefined reference to `timer_getoverrun'
/tmp/ccY0iuGU.o: In function `main':
timer_create.c:(.text+0x21e): undefined reference to `timer_create'
timer_create.c:(.text+0x318): undefined reference to `timer_settime'
collect2: error: ld returned 1 exit status

$> gcc -lrt timer_create.c 
$> ./a.out    
Usage: ./a.out <sleep-secs> <freq-nanosecs>

$> ./a.out 4 1
Establishing handler for signal 34
Blocking signal 34
timer ID is 0x9a10008
Sleeping for 4 seconds
Unblocking signal 34
Caught signal 34
    sival_ptr = 0xbfe27734;     *sival_ptr = 0x9a10008
    overrun count = -294661441
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to resolve EAGAIN (errno 11) from timer_create? codeblazer Linux - Newbie 0 07-03-2012 06:08 PM
C timer_create skeleton newbie14 Programming 10 01-09-2012 11:09 PM
timer_create failing manohar Programming 3 06-21-2011 12:18 PM
[C/C++] Using timer_create() and interrupting sleep() dwhitney67 Programming 0 05-19-2009 07:30 AM
Timer Deadlock problem in timer_create and delete_timer nkk4u Programming 0 04-15-2005 02:10 AM

All times are GMT -5. The time now is 11:51 PM.

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