LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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
 
LinkBack Search this Thread
Old 02-27-2008, 01:59 PM   #1
rvca
LQ Newbie
 
Registered: Dec 2005
Location: Vancouver
Distribution: Debian/Ubuntu
Posts: 28

Rep: Reputation: 15
Linux kernel API. Cflags needed?


Hi all,

I'm trying to compile a C timer using the linux kernel API without any success. When I include the <linux/ktime.h> file i get a bunch of errors:

Code:
In file included from /usr/include/asm-x86_64/div64.h:1,
from /usr/include/asm/div64.h:8,
from /usr/include/linux/calc64.h:5,
from /usr/include/linux/jiffies.h:4,
from /usr/include/linux/ktime.h:25,
from /z/roberto/personal_files/research/prototype-v0-20/implementation/test/src/test.c:30:
/usr/include/asm-generic/div64.h:1:2: error: #error Do not include div64.h.
In file included from /usr/include/linux/jiffies.h:4,
from /usr/include/linux/ktime.h:25,
/z/roberto/personal_files/research/prototype-v0-20/implementation/test/src/test.c:30:
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/include/linux/jiffies.h:256:47: error: division by zero in #if
/usr/include/linux/jiffies.h: In function ‘jiffies_to_msecs’:
/usr/include/linux/jiffies.h:259: error: ‘MSEC_PER_SEC’ undeclared (first use in this function)
/usr/include/linux/jiffies.h:267:47: error: division by zero in #if
/usr/include/linux/jiffies.h: In function ‘jiffies_to_usecs’:
/usr/include/linux/jiffies.h:270: error: ‘USEC_PER_SEC’ undeclared (first use in this function)
/usr/include/linux/jiffies.h:280:47: error: division by zero in #if
/usr/include/linux/jiffies.h: In function ‘msecs_to_jiffies’:
/usr/include/linux/jiffies.h:283: error: ‘MSEC_PER_SEC’ undeclared (first use in this function)
/usr/include/linux/jiffies.h:293:47: error: division by zero in #if
/usr/include/linux/jiffies.h: In function ‘usecs_to_jiffies’:
/usr/include/linux/jiffies.h:296: error: ‘USEC_PER_SEC’ undeclared (first use in this function)
/usr/include/linux/jiffies.h: In function ‘timespec_to_jiffies’:
/usr/include/linux/jiffies.h:315: error: ‘CLOCK_TICK_RATE’ undeclared (first use in this function)
/usr/include/linux/jiffies.h:317: error: called object ‘u64’ is not a function
/usr/include/linux/jiffies.h:317: error: called object ‘u64’ is not a function
/usr/include/linux/jiffies.h:317: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/include/linux/jiffies.h:318: error: called object ‘u64’ is not a function
/usr/include/linux/jiffies.h:318: error: called object ‘u64’ is not a function
/usr/include/linux/jiffies.h:321: error: expected ‘)’ before ‘sec’
/usr/include/linux/jiffies.h:322: error: expected ‘)’ before ‘nsec’
/usr/include/linux/jiffies.h: In function ‘jiffies_to_timespec’:

....
Line 30 is: #include <linux/ktime.h>

And it goes on an on... I'm sure I'm missing the appropriate CFLAGS. Since I am new to the Linux Kernel API I don't know them and I still haven't found them on the documentation.

(the code doesn't even have anything... it's a main function with printf"hello world".)


Thanx.

EDIT: i'm using GCC -O0 -g3

Last edited by rvca; 02-27-2008 at 02:00 PM.
 
Old 02-27-2008, 09:00 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 64
It seems as if you are including system include files. You should be including kernel header files. Unless you are working with 2.4, you shouldn’t need to specify the include dirs and macros manually at the commandline. Just create a Makefile for the 2.6 kernel build system. This is in any up-to-date tutorial on kernel programming.
 
Old 02-28-2008, 12:20 AM   #3
rvca
LQ Newbie
 
Registered: Dec 2005
Location: Vancouver
Distribution: Debian/Ubuntu
Posts: 28

Original Poster
Rep: Reputation: 15
Done

Thank you for your help.

Done.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux needs file-scanning API on kernel like it's 1996 LXer Syndicated Linux News 0 10-23-2006 01:03 AM
Test Kernel API dongthao Programming 0 05-03-2006 12:42 PM
Linux Kernel API Question Neruocomp Programming 2 06-23-2005 07:24 PM
CFLAGS to compile kernel frzburn Linux - Software 4 03-05-2005 05:42 AM
./configure, CFLAGS, checkinstall, and kernel arch type rgiggs Slackware 3 12-28-2004 01:39 AM


All times are GMT -5. The time now is 04:53 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration