Über mich
Amiga FAQ
Lustige Texte

Tom's Homepage

How to create PPC stubs for M68K libraries

This short reference describes how I made the PPC stubs for Paul Huxham's jpeg.library.

What we need:

Prepare the tools

If you have VBCC installed, fd2pragma is already present and no further action is needed.

Otherwise unpack fd2pragma.lha and copy fd2pragma and fd2pragma.types to a place in your DOS path. SDK:C (where IDLToool is) is a good place.

Let's start

Unpack the library archive to your HDD. I used Work:dev as destination, so I now have a directory Work:dev/jpeg.library/dev which contains all the developer information. There I created a subdirectory called OS4 for my work.

Make Work:dev/jpeg.library/dev/OS4 your current directory.

lha x jpeglibrary.lha work:dev/
cd work:dev/jpeg.library/dev
makedir OS4
cd os4

First step - copy and edit include files

First we copy the include and fd files from the developer directory to our work directory.

copy /includes include all
copy /fd fd all

Now we need to edit the include files, because they contain many references to 68k registers and old compiler instructions.

Remove all occurences of


from all include files.

Second step - create makefile

create a makefile with the following contents:

all: jpeg.l.main

jpeg.xml: fd/jpeg.fd include/jpeg/jpeg_protos.h
	fd2pragma infile fd/jpeg.fd clib include/jpeg/jpeg_protos.h special 140

jpeg.c: fd/jpeg.fd include/jpeg/jpeg_protos.h
	fd2pragma infile fd/jpeg.fd clib include/jpeg/jpeg_protos.h special 141

include/interfaces/jpeg.h: jpeg.xml
	idltool -p -i -n -c jpeg.xml

jpeg.l.main: jpeg.c include/interfaces/jpeg.h
	gcc -Iinclude -nostartfiles $< -o $@

The makefile executes the following steps:

  • use fd2pragma to create an xml file for the new library
  • use fd2pragma to create the code for the new library
  • use idltool to create the OS4 include files from the xml file
  • use gcc to compile the code and create the stub library

Third step - correct the errors

fd2pragma has made a several mistakes when creating the stub functions, so we have to correct them manually.

First we have to include jpeg/jpeg.h and interfaces/jpeg.h just before jpeg_vectors.h in jpeg.c:

#include <interfaces/exec.h>
#include <jpeg/jpeg.h>
#include <interfaces/jpeg.h>
#include "jpeg_vectors.c"

Then the name "colorMap" seems to be hard coded without any reference to our current project.

This has to be replaced by the name of the argument before "..." in the function declaration.

For jpeg.c this is in all cases jph.

Now enter make to build the library.


Well, that's it. The only thing to do is to copy jpeg.l.main to libs: and to move the include files from the include directory to SDK:local/common/include so we can use the library in our programs.


Letzte Änderung / Last Update: 30-Dez-2006