Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

You may need to add the path. On the gcc command line:

gcc -I/usr/src/linux-2.6.32-gentoo/arch/x86/include ...

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

Add -I/usr/src/linux-2.6.32-gentoo/arch/x86/include to your compile command line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top