Reputation: 235
I am using gentoo and trying to compile a program to control the bits on the parallel port. It has this line near the top of it:
#include <asm/io.h>
And when I try to use gcc on it, it produces this output:
port.c:4:20: error: asm/io.h: No such file or directory
"locate asm/io.h" yeilds (among other things):
/usr/src/linux-2.6.32-gentoo/arch/x86/include/asm/io.h
So I have the header file, but it's not finding it? Why is this not working?
Upvotes: 9
Views: 30614
Reputation: 727
This answer maybe not for your condition, but I hope it can help others.
For me, when I try to make my driver, I met same problem, at last, I fixed it by correct my Makefile
from:
obj-m += t.o
KDIR:=/lib/modules/$(shell uname -r)/build
MAKE:=make
t-objs: main.o base.o
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
to
obj-m += t.o
KDIR:=/lib/modules/$(shell uname -r)/build
MAKE:=make
t-objs:= main.o base.o
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
Upvotes: 0
Reputation: 2428
Never use the code/headers in /usr/include/asm
. Use the headers in /usr/include/sys
instead.
What you are doing by using /usr/include/asm/
is building your code against a specific revision of the Kernel headers. This is subject to breakage when the kernel headers change. By linking to the other location, you will link to a more stable form of the headers in glibc, which will refer to the kernel headers as needed. That's why there's a large complex of #ifdef ... #endif
lines peppered all in the headers.
Trust me, all the tools you need for bit-fiddling with the parallel ports will be in /usr/include/sys/io.h
, since probably all you're going to be using are direct readb()
and writeb()
calls to the appropriate /dev/lpX
device.
Upvotes: 4
Reputation: 96141
I am not sure if you are the author of the program or you're just trying to compile a program you got from someone, but looks like #include <asm/io.h>
should be replaced with #include <sys/io.h>
. See the results of this google search for more information.
Upvotes: 13
Reputation: 1184
Add -I/usr/src/linux-2.6.32-gentoo/arch/x86/include to your compile command line.
Upvotes: 0
Reputation: 22290
try
gcc -I/usr/src/linux-2.6.32-gentoo/arch/x86/include xyx
where xyz is the file you're trying to compile.
This tells the compiler where to look for include files. You can have many -I options if your include files are in different locations, like this
gcc -I/usr/src/linux-2.6.32-gentoo/arch/x86/include -I/usr/src/some/Dir xyx
Upvotes: 1
Reputation:
You may need to add the path. On the gcc command line:
gcc -I/usr/src/linux-2.6.32-gentoo/arch/x86/include ...
Upvotes: 0