Note: Please see the file INSTALL, located in the root directory of the parapin distribution, for details on building and installing parapin on your system.
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
in the location given in the parapin Makefile as
$/include.
Important: 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.
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.
Important: 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 Makefiles that come with Parapin compiles Parapin into its own independent module, called kparapin.o. This module can be inserted into the kernel using modprobe (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:
-D__KERNEL__
directive, but without the
-DMODULE directive.
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 with the modprobe command before inserting any modules that use Parapin; otherwise, you will get unresolved symbols.
When building a userspace program that will make use of the parapindriver interface to kparapin, you must include parapindriver.h. This header file defines the device-specific ioctl commands used to communicate with the device driver. It also includes parapin.h, so your program can make use of all the ``LP_*'' constants. The parapindriver system calls take arguments using these constants and pass them unchanged down to the kparapin routines.