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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-27-2006, 08:56 AM
|
#1
|
|
LQ Newbie
Registered: Apr 2006
Posts: 4
Rep:
|
Trying to Compile "hello world" Kernel Module (please help!)
Hello,
I am trying to compile an example from the Oreilly Press book "Linux Device Drivers". Here is the example code:
Code:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
The problem is that when i try to compile with this: gcc -c -I /usr/src/linux-2.6.16/include/ hello.c , I get all of this:
Code:
In file included from /usr/src/linux-2.6.16/include/linux/sched.h:12,
from /usr/src/linux-2.6.16/include/linux/module.h:10,
from hello.c:2:
/usr/src/linux-2.6.16/include/linux/jiffies.h:75: error: syntax error before ‘jiffies_64’
/usr/src/linux-2.6.16/include/linux/jiffies.h:79: error: syntax error before ‘get_jiffies_64’
/usr/src/linux-2.6.16/include/linux/jiffies.h:79: warning: data definition has no type or storage class
In file included from /usr/src/linux-2.6.16/include/linux/sched.h:12,
from /usr/src/linux-2.6.16/include/linux/module.h:10,
from hello.c:2:
/usr/src/linux-2.6.16/include/linux/jiffies.h:250:47: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘jiffies_to_msecs’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:253: error: ‘MSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:253: error: (Each undeclared identifier is reported only once
/usr/src/linux-2.6.16/include/linux/jiffies.h:253: error: for each function it appears in.)
/usr/src/linux-2.6.16/include/linux/jiffies.h:261:47: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘jiffies_to_usecs’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:264: error: ‘USEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:274:47: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘msecs_to_jiffies’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:277: error: ‘MSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:287:47: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘usecs_to_jiffies’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:290: error: ‘USEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘timespec_to_jiffies’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:311: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:311: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:311: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:312: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:312: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:315: error: syntax error before ‘sec’
/usr/src/linux-2.6.16/include/linux/jiffies.h:315: error: syntax error before ‘NSEC_PER_SEC’
/usr/src/linux-2.6.16/include/linux/jiffies.h:315: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:315: error: syntax error before ‘)’ token
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘jiffies_to_timespec’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:328: error: syntax error before ‘nsec’
/usr/src/linux-2.6.16/include/linux/jiffies.h:329: error: ‘nsec’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:329: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘timeval_to_jiffies’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:350: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:350: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:350: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:351: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:351: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:354: error: syntax error before ‘sec’
/usr/src/linux-2.6.16/include/linux/jiffies.h:354: error: syntax error before ‘NSEC_PER_SEC’
/usr/src/linux-2.6.16/include/linux/jiffies.h:354: error: called object ‘u64’ is not a function
/usr/src/linux-2.6.16/include/linux/jiffies.h:354: error: syntax error before ‘)’ token
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘jiffies_to_timeval’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:366: error: syntax error before ‘nsec’
/usr/src/linux-2.6.16/include/linux/jiffies.h:369: error: ‘nsec’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:369: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:370: error: ‘NSEC_PER_USEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:379:41: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h:379:42: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘jiffies_to_clock_t’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:382: error: syntax error before ‘tmp’
/usr/src/linux-2.6.16/include/linux/jiffies.h:383: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:383: error: ‘USER_HZ’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:383: error: ‘tmp’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:383: error: invalid lvalue in asm output 0
/usr/src/linux-2.6.16/include/linux/jiffies.h:390:18: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘clock_t_to_jiffies’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:395: error: syntax error before ‘jif’
/usr/src/linux-2.6.16/include/linux/jiffies.h:398: error: ‘USER_HZ’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:402: error: ‘jif’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:402: error: syntax error before numeric constant
/usr/src/linux-2.6.16/include/linux/jiffies.h:403: error: invalid lvalue in asm output 0
/usr/src/linux-2.6.16/include/linux/jiffies.h: At top level:
/usr/src/linux-2.6.16/include/linux/jiffies.h:408: error: syntax error before ‘jiffies_64_to_clock_t’
/usr/src/linux-2.6.16/include/linux/jiffies.h:408: error: syntax error before ‘x’
/usr/src/linux-2.6.16/include/linux/jiffies.h:410:41: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h:410:42: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘jiffies_64_to_clock_t’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:418: error: ‘x’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:419: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:419: error: ‘USER_HZ’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:419: error: invalid lvalue in asm output 0
/usr/src/linux-2.6.16/include/linux/jiffies.h: At top level:
/usr/src/linux-2.6.16/include/linux/jiffies.h:424: error: syntax error before ‘nsec_to_clock_t’
/usr/src/linux-2.6.16/include/linux/jiffies.h:424: error: syntax error before ‘x’
/usr/src/linux-2.6.16/include/linux/jiffies.h:426:28: error: division by zero in #if
/usr/src/linux-2.6.16/include/linux/jiffies.h: In function ‘nsec_to_clock_t’:
/usr/src/linux-2.6.16/include/linux/jiffies.h:427: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:427: error: ‘USER_HZ’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:427: error: ‘x’ undeclared (first use in this function)
/usr/src/linux-2.6.16/include/linux/jiffies.h:427: error: invalid lvalue in asm output 0
In file included from /usr/src/linux-2.6.16/include/linux/cpumask.h:86,
from /usr/src/linux-2.6.16/include/linux/sched.h:15,
from /usr/src/linux-2.6.16/include/linux/module.h:10,
from hello.c:2:
LOTS OF STUFF HERE!!!!!!!
hello.c: In function ‘hello_init’:
hello.c:9: error: ‘KERN_ALERT’ undeclared (first use in this function)
hello.c:9: error: syntax error before string constant
hello.c: In function ‘hello_exit’:
hello.c:15: error: ‘KERN_ALERT’ undeclared (first use in this function)
hello.c:15: error: syntax error before string constant
|
|
|
|
04-27-2006, 02:09 PM
|
#2
|
|
LQ Newbie
Registered: Apr 2006
Posts: 4
Original Poster
Rep:
|
Please!
PLEASE! There must be someone who knows about this stuff that I can talk to.
|
|
|
|
04-27-2006, 02:52 PM
|
#3
|
|
Member
Registered: Nov 2001
Posts: 75
Rep:
|
No, put the hello.c in your home dir or somewhere, not in the true kernel source. If its in your homedir, cd into the home dir and do this:
make -C /usr/src/linux-2.6.16/ M=`pwd` modules
Last edited by Vagrant; 04-27-2006 at 03:00 PM.
|
|
|
|
04-27-2006, 03:10 PM
|
#4
|
|
LQ Newbie
Registered: Apr 2006
Posts: 4
Original Poster
Rep:
|
Hey, thanks for the reply. THe command that you posted is used to make the actual module from the object file, am I correct? My problem is that I cant make the object file itself using my program and the kernel source. The command that I used above was run on hello.c in my home directory as well as the kernel directory and both dont work. How is it that I compile my hello.c into an object file without such errors?
|
|
|
|
04-27-2006, 03:15 PM
|
#5
|
|
Member
Registered: Nov 2001
Posts: 75
Rep:
|
Did you use the command I posted?
|
|
|
|
04-27-2006, 03:21 PM
|
#6
|
|
LQ Newbie
Registered: Apr 2006
Posts: 4
Original Poster
Rep:
|
.....My apologies. Um, yes that worked quite well. What exactly does that command do, and how does it know what c file to compile? Oh and THANKS!
Oh, yea, and I understand that its using the make command and the appropriate Makefile. But I dont understand how this make syntax works.
Last edited by antdengineer; 04-27-2006 at 03:26 PM.
|
|
|
|
04-27-2006, 03:53 PM
|
#7
|
|
Member
Registered: Nov 2001
Posts: 75
Rep:
|
Its using the make file in the kernel source directory. Since your file is ".c," and you did "make modules," all the .c files that are supplied in the "M=" directory, for which you supplsed `pwd1, are treated as modules. There is a discussion in that book about this in the section called "Compiling and Loading Modules" or something like that.
Glad to help.
|
|
|
|
09-26-2009, 11:59 PM
|
#8
|
|
LQ Newbie
Registered: Sep 2009
Distribution: ubuntu-9.04
Posts: 1
Rep:
|
Hi,
I am using ubuntu-9.04 and have compiled kernel 2.6.28.10.
I tried to compile my "hello-world" module using the above command
I am still getting the following errors.
Code:
"make -C /usr/src/linux" M=`pwd`
In file included from include/linux/types.h:11,
from include/linux/prefetch.h:13,
from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/posix_types.h:47:29: error: asm/posix_types.h: No such file or directory
In file included from include/linux/prefetch.h:13,
from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/types.h:12:23: error: asm/types.h: No such file or directory
In file included from include/linux/prefetch.h:13,
from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/types.h:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__kernel_dev_t’
include/linux/types.h:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dev_t’
include/linux/types.h:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ino_t’
include/linux/types.h:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mode_t’
include/linux/types.h:22: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘nlink_t’
include/linux/types.h:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘off_t’
include/linux/types.h:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pid_t’
include/linux/types.h:25: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘daddr_t’
include/linux/types.h:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘suseconds_t’
include/linux/types.h:28: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘timer_t’
include/linux/types.h:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘clockid_t’
include/linux/types.h:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uid_t’
include/linux/types.h:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gid_t’
include/linux/types.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uid16_t’
include/linux/types.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gid16_t’
include/linux/types.h:44: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘old_uid_t’
include/linux/types.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘old_gid_t’
include/linux/types.h:57: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘loff_t’
include/linux/types.h:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘size_t’
include/linux/types.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ssize_t’
include/linux/types.h:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ptrdiff_t’
include/linux/types.h:81: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘time_t’
include/linux/types.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘clock_t’
include/linux/types.h:91: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘caddr_t’
include/linux/types.h:109: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int8_t’
include/linux/types.h:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int8_t’
include/linux/types.h:111: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int16_t’
include/linux/types.h:112: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int16_t’
include/linux/types.h:113: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int32_t’
include/linux/types.h:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int32_t’
include/linux/types.h:118: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint8_t’
include/linux/types.h:119: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint16_t’
include/linux/types.h:120: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
include/linux/types.h:123: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint64_t’
include/linux/types.h:124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int64_t’
include/linux/types.h:125: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int64_t’
include/linux/types.h:140: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘sector_t’
include/linux/types.h:149: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘blkcnt_t’
include/linux/types.h:180: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__le16’
include/linux/types.h:181: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__be16’
include/linux/types.h:182: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__le32’
include/linux/types.h:183: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__be32’
include/linux/types.h:185: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__le64’
include/linux/types.h:186: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__be64’
include/linux/types.h:188: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__sum16’
include/linux/types.h:189: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__wsum’
include/linux/types.h:198: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘phys_addr_t’
include/linux/types.h:201: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘resource_size_t’
include/linux/types.h:204: error: expected specifier-qualifier-list before ‘__kernel_daddr_t’
In file included from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/prefetch.h:14:27: error: asm/processor.h: No such file or directory
include/linux/prefetch.h:15:23: error: asm/cache.h: No such file or directory
In file included from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/prefetch.h:53: error: expected declaration specifiers or ‘...’ before ‘size_t’
In file included from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/list.h:7:24: error: asm/system.h: No such file or directory
In file included from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/linux/stat.h:6:22: error: asm/stat.h: No such file or directory
In file included from include/linux/kernel.h:11,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/linux/linkage.h:5:25: error: asm/linkage.h: No such file or directory
In file included from include/asm/bitops.h:12,
from include/linux/bitops.h:17,
from include/linux/kernel.h:15,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/asm-generic/bitops/atomic.h:7:26: error: asm/spinlock.h: No such file or directory
In file included from include/asm/bitops.h:12,
from include/linux/bitops.h:17,
from include/linux/kernel.h:15,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/asm-generic/bitops/atomic.h:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__atomic_hash’
include/asm-generic/bitops/atomic.h: In function ‘set_bit’:
include/asm-generic/bitops/atomic.h:66: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:66: error: (Each undeclared identifier is reported only once
include/asm-generic/bitops/atomic.h:66: error: for each function it appears in.)
include/asm-generic/bitops/atomic.h:70: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: implicit declaration of function ‘local_irq_save’
include/asm-generic/bitops/atomic.h:70: error: implicit declaration of function ‘__raw_spin_lock’
include/asm-generic/bitops/atomic.h:72: error: implicit declaration of function ‘__raw_spin_unlock’
include/asm-generic/bitops/atomic.h:72: error: implicit declaration of function ‘local_irq_restore’
include/asm-generic/bitops/atomic.h: In function ‘clear_bit’:
include/asm-generic/bitops/atomic.h:87: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘change_bit’:
include/asm-generic/bitops/atomic.h:108: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘test_and_set_bit’:
include/asm-generic/bitops/atomic.h:128: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘test_and_clear_bit’:
include/asm-generic/bitops/atomic.h:152: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘test_and_change_bit’:
include/asm-generic/bitops/atomic.h:175: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
In file included from include/asm/bitops.h:13,
from include/linux/bitops.h:17,
from include/linux/kernel.h:15,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/asm-generic/bitops/non-atomic.h: In function ‘__set_bit’:
include/asm-generic/bitops/non-atomic.h:17: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__clear_bit’:
include/asm-generic/bitops/non-atomic.h:25: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__change_bit’:
include/asm-generic/bitops/non-atomic.h:42: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__test_and_set_bit’:
include/asm-generic/bitops/non-atomic.h:59: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__test_and_clear_bit’:
include/asm-generic/bitops/non-atomic.h:78: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__test_and_change_bit’:
include/asm-generic/bitops/non-atomic.h:90: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘test_bit’:
include/asm-generic/bitops/non-atomic.h:105: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
...And So on...
Help please.
Varad
|
|
|
|
09-28-2009, 01:40 PM
|
#9
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Rep: 
|
Quote:
Originally Posted by Varad
Hi,
I am using ubuntu-9.04 and have compiled kernel 2.6.28.10.
I tried to compile my "hello-world" module using the above command
I am still getting the following errors.
Code:
"make -C /usr/src/linux" M=`pwd`
In file included from include/linux/types.h:11,
from include/linux/prefetch.h:13,
from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/posix_types.h:47:29: error: asm/posix_types.h: No such file or directory
In file included from include/linux/prefetch.h:13,
from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/types.h:12:23: error: asm/types.h: No such file or directory
In file included from include/linux/prefetch.h:13,
from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/types.h:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__kernel_dev_t’
include/linux/types.h:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dev_t’
include/linux/types.h:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ino_t’
include/linux/types.h:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mode_t’
include/linux/types.h:22: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘nlink_t’
include/linux/types.h:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘off_t’
include/linux/types.h:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pid_t’
include/linux/types.h:25: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘daddr_t’
include/linux/types.h:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘suseconds_t’
include/linux/types.h:28: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘timer_t’
include/linux/types.h:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘clockid_t’
include/linux/types.h:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uid_t’
include/linux/types.h:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gid_t’
include/linux/types.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uid16_t’
include/linux/types.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gid16_t’
include/linux/types.h:44: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘old_uid_t’
include/linux/types.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘old_gid_t’
include/linux/types.h:57: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘loff_t’
include/linux/types.h:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘size_t’
include/linux/types.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ssize_t’
include/linux/types.h:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ptrdiff_t’
include/linux/types.h:81: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘time_t’
include/linux/types.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘clock_t’
include/linux/types.h:91: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘caddr_t’
include/linux/types.h:109: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int8_t’
include/linux/types.h:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int8_t’
include/linux/types.h:111: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int16_t’
include/linux/types.h:112: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int16_t’
include/linux/types.h:113: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int32_t’
include/linux/types.h:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int32_t’
include/linux/types.h:118: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint8_t’
include/linux/types.h:119: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint16_t’
include/linux/types.h:120: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
include/linux/types.h:123: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint64_t’
include/linux/types.h:124: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_int64_t’
include/linux/types.h:125: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int64_t’
include/linux/types.h:140: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘sector_t’
include/linux/types.h:149: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘blkcnt_t’
include/linux/types.h:180: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__le16’
include/linux/types.h:181: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__be16’
include/linux/types.h:182: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__le32’
include/linux/types.h:183: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__be32’
include/linux/types.h:185: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__le64’
include/linux/types.h:186: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__be64’
include/linux/types.h:188: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__sum16’
include/linux/types.h:189: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__wsum’
include/linux/types.h:198: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘phys_addr_t’
include/linux/types.h:201: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘resource_size_t’
include/linux/types.h:204: error: expected specifier-qualifier-list before ‘__kernel_daddr_t’
In file included from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/prefetch.h:14:27: error: asm/processor.h: No such file or directory
include/linux/prefetch.h:15:23: error: asm/cache.h: No such file or directory
In file included from include/linux/list.h:6,
from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/prefetch.h:53: error: expected declaration specifiers or ‘...’ before ‘size_t’
In file included from include/linux/module.h:9,
from /home/varad/hello.c:2:
include/linux/list.h:7:24: error: asm/system.h: No such file or directory
In file included from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/linux/stat.h:6:22: error: asm/stat.h: No such file or directory
In file included from include/linux/kernel.h:11,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/linux/linkage.h:5:25: error: asm/linkage.h: No such file or directory
In file included from include/asm/bitops.h:12,
from include/linux/bitops.h:17,
from include/linux/kernel.h:15,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/asm-generic/bitops/atomic.h:7:26: error: asm/spinlock.h: No such file or directory
In file included from include/asm/bitops.h:12,
from include/linux/bitops.h:17,
from include/linux/kernel.h:15,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/asm-generic/bitops/atomic.h:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__atomic_hash’
include/asm-generic/bitops/atomic.h: In function ‘set_bit’:
include/asm-generic/bitops/atomic.h:66: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:66: error: (Each undeclared identifier is reported only once
include/asm-generic/bitops/atomic.h:66: error: for each function it appears in.)
include/asm-generic/bitops/atomic.h:70: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:70: error: implicit declaration of function ‘local_irq_save’
include/asm-generic/bitops/atomic.h:70: error: implicit declaration of function ‘__raw_spin_lock’
include/asm-generic/bitops/atomic.h:72: error: implicit declaration of function ‘__raw_spin_unlock’
include/asm-generic/bitops/atomic.h:72: error: implicit declaration of function ‘local_irq_restore’
include/asm-generic/bitops/atomic.h: In function ‘clear_bit’:
include/asm-generic/bitops/atomic.h:87: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:91: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘change_bit’:
include/asm-generic/bitops/atomic.h:108: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:112: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘test_and_set_bit’:
include/asm-generic/bitops/atomic.h:128: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:133: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘test_and_clear_bit’:
include/asm-generic/bitops/atomic.h:152: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:157: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h: In function ‘test_and_change_bit’:
include/asm-generic/bitops/atomic.h:175: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘raw_spinlock_t’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘s’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘__atomic_hash’ undeclared (first use in this function)
include/asm-generic/bitops/atomic.h:180: error: ‘L1_CACHE_BYTES’ undeclared (first use in this function)
In file included from include/asm/bitops.h:13,
from include/linux/bitops.h:17,
from include/linux/kernel.h:15,
from include/linux/cache.h:4,
from include/linux/time.h:7,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from /home/varad/hello.c:2:
include/asm-generic/bitops/non-atomic.h: In function ‘__set_bit’:
include/asm-generic/bitops/non-atomic.h:17: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__clear_bit’:
include/asm-generic/bitops/non-atomic.h:25: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__change_bit’:
include/asm-generic/bitops/non-atomic.h:42: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__test_and_set_bit’:
include/asm-generic/bitops/non-atomic.h:59: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__test_and_clear_bit’:
include/asm-generic/bitops/non-atomic.h:78: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘__test_and_change_bit’:
include/asm-generic/bitops/non-atomic.h:90: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
include/asm-generic/bitops/non-atomic.h: In function ‘test_bit’:
include/asm-generic/bitops/non-atomic.h:105: error: ‘BITS_PER_LONG’ undeclared (first use in this function)
...And So on...
Help please.
Varad
|
maybe you used something that isnt allowed in the module
without the code its impossable to tell
|
|
|
|
12-04-2010, 04:07 AM
|
#10
|
|
LQ Newbie
Registered: Dec 2010
Posts: 2
Rep:
|
this worked for me
Makefile
Code:
obj-m = hello.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
hello.c
Code:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:18 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|