next up previous
Next: Initialization and Shutdown Up: PARAPIN: A Parallel Port Previous: Parapin Basics

Subsections


Compiling and Linking

The C Library Version

The user-space version of Parapin is compiled and linked very much like any other C library. If you installed Parapin on your system using ``make install'', the library (libparapin.a) was probably installed in /usr/local/lib. The header file with the library's function prototypes and other definitions, parapin.h, is probably also in /usr/local/include.

Note well: Parapin must be compiled with gcc using compiler optimization of -O or better. This is because Parapin uses the inb and outb functions that exist only with compiler optimization.

To use the library, first make sure to #include parapin.h in your C source file. When linking, add -lparapin along with any other libraries you might be using.

The Kernel Module Version

As with the C library version, kernel source code that uses Parapin must #include parapin.h. Make sure that __KERNEL__ is defined before the include statement.

Note well: Parapin must be compiled with gcc using compiler optimization of -O or better. This is because Parapin uses the inb and outb functions that exist only with compiler optimization.

Linking is a little more complicated. As with any other interdependent kernel modules, there are actually two ways of using parapin with your Linux device driver:

The Makefile that comes with Parapin compiles Parapin into its own independent module, called kparapin.o. This module can be inserted into the kernel using insmod (as described in the first method). If you'd rather use the second method, and link Parapin directly with your device driver module instead, do the following:

  1. Copy parapin.c into your driver's source directory.
  2. In your driver's Makefile, compile kparapin.o from parapin.c, with the -D__KERNEL__ directive, but without the -DMODULE directive.
  3. Link kparapin.o with all the other object files that make up your driver.

If your driver only consists of one other source file, and you have never linked multiple .o's together into a single kernel module, it's easy. First, compile each .c file into a .o using gcc -c (the same as with normal C programs that span multiple source files); then, link all the .o's together into one big .o using ld -i -o final-driver.o component1.o component2.o component3.o ....

Important note: Whichever method you use, Parapin also requires functions provided by the standard Linux kernel module parport. Make sure you insert the parport module before inserting any modules that use Parapin; otherwise, you will get unresolved symbols.


next up previous
Next: Initialization and Shutdown Up: PARAPIN: A Parallel Port Previous: Parapin Basics
Jeremy Elson 2000-03-30