" causes "error: asm / io.h: There is no such file or directory" I am using gentoo and trying to compile a program for contro...">

"#include <asm / io.h>" causes "error: asm / io.h: There is no such file or directory"

I am using gentoo and trying to compile a program for controlling bits on a parallel port. He has this line near the top:

#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

"find asm / io.h" yeilds (by the way):

/usr/src/linux-2.6.32-gentoo/arch/x86/include/asm/io.h

So, I have a header file, but it does not find it? Why is this not working?

+7
c parallel-port gentoo
source share
5 answers

I'm not sure if you are the author of the program, or just trying to compile a program that you received from someone, but it looks like #include <asm/io.h> should be replaced by #include <sys/io.h> . See the results of this google search for more information.

+10
source share

Never use the code / headers in /usr/include/asm . Use the /usr/include/sys headers instead.

What you do using /usr/include/asm/ creates your code against a specific revision of the kernel headers. This can lead to breakage when changing kernel headers. When linking to another location, you will refer to a more stable form of headers in glibc, which will refer to kernel headers as needed. That's why a large array of #ifdef ... #endif strings #ifdef ... #endif sliced ​​everything in the headers.

Believe me, all the tools needed to use parallel ports in parallel will be in /usr/include/sys/io.h , since probably all you are going to use are direct calls to readb() and writeb() for the corresponding /dev/lpX .

+4
source share

You may need to add a path. At the gcc command prompt:

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

to try

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

where xyz is the file you are trying to compile.

This tells the compiler where to look for included files. You can have many -I options if your include files are in different places, like

 gcc -I/usr/src/linux-2.6.32-gentoo/arch/x86/include -I/usr/src/some/Dir xyx 
0
source share

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

0
source share

All Articles