views:

979

answers:

4

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?

A: 

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

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

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
Glen
Thanks, this fixed that problem. The only problem now is that that file pulls in a bunch of other files, one of which (asm-generic/ioctls.h) simply doesn't exist on my dard drive...the sad part is that /usr/include/asm-generic/ioctl.h is present. Typo in header perhaps?
marcusw
See my answer. Looks like very old code, and trying to get it to work on a modern linux kernel might be a lot of trouble. May I know what library/code it is?
Alok
It is parcon, from http://bigasterisk.com/projects/parallel. While there is a binary on the site, I don't want to use that because I want to be able to customize the program to suit my needs. Anyway, I added a symlink from ioctls.h to ioctl.h in /usr/include/asm-generic, plus an -I/usr/src/linux/include switch on the command line, and now am getting a bunch of errors in io.h regarding syntax errors and undefined variables. Maybe the symlink was not to the right file?
marcusw
As I said in my answer, try replacing `asm/io.h` with `sys/io.h`. http://homebrewtechnology.blogspot.com/2009/03/internet-controled-car-v2-parallel-port.html seems to suggest it works.
Alok
Also, you can't just link similarly named files like this and assume it will work :-).
Alok
Changing to sys/io.h worked great without any other hacking. Thank you!
marcusw
A: 

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

bobmcn
+1  A: 

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.

Alok
This worked flawlessly, thanks!
marcusw
Glad to be of help.
Alok