#include-ing certain header files in old C source (page.h et al) on Ubuntu

c, header-files, linux

Solution

There are two different sets of header files: one for Linux kernel programming, the other for general user-space programs.

/usr/src/linux* is for the kernel stuff.

/usr/include/* are the "normal" headers.

You do not want to mix'n'match the two.

If you're programming a game, I'd strongly encourage you to look at SDL or OpenGL:

http://www.linuxjournal.com/article/6410

http://content.gpwiki.org/index.php/SDL:Tutorials

http://www.opengl.org/wiki/Getting_Started

http://www.dreamincode.net/forums/topic/63945-game-programming-in-linux-for-windows-programmers-part-1/

ADDENDUM:

The problem is you're missing the fbdev (user-space) headers. You do NOT want to bring in any Linux kernel source headers.

You should be able to get the header with this command:

`sudo apt-get xserver-xorg-video-fbdev`

You might need to bring in other dependencies as well - apt-get should tell you.

'Hope that helps .. PSM

PS:

It appears that your book, "Programming Linux Games" is also a well-regarded tutorial on SDL.

Problem

I'm new to GNU/Linux (Lubuntu 11.10) and am trying to compile some C source code out of a Linux programming book from 2001. Am somewhat confused about the inclusion of header files in GNU/Linux. The program is "simplefb.c" from the book Programming Linux Games by John R. Hall et al (2001). I jumped straight to the chapter on console programming with framebuffer but hit this immediate snag. Would just like to make some simple non-GUI (and non-'text') games in C on Linux for fun... The problem seems to be with a few #includes to header files: ``` #include <asm/page.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <linux/fb.h> ``` Trying the code as given in the book: > cc the_file.c gives fatal error: asm/page.h: No such file or directory compilation terminated. And indeed it seems that these files live somewhere else (nowadays?) so I tried amending initially just the first #include to: ``` #include </usr/src/linux-headers-3.0.0-17-generic/include/asm-generic/page.h> ``` I chose this particular folder of headers (there are several in /usr/src/) because > uname -r 3.0.0-17-generic With the amended #include, I then get the compilation error: In file included from the_file.c /usr/src/linux-headers-3.0.0-17-generic/include/asm-generic/page.h:96:38: fatal error: asm- generic/memory_model.h: No such file or directory compilation terminated. And looking in that page.h, it specifies include asm-generic/memory_model.h (removed the hashs and 'tags' as this line won't show up here properly otherwise) but this file does exist in the same folder. So, before I go on a wild-goose-chase (firstly removing the asm-generic/ bit of the previous include and putting it in quotes), what is the correct procedure I should be using here? Is there an obvious right way to get the book source code to compile? Thank you. Will be most grateful for any help.

Original source