Click Here
home features news forums classifieds faqs links search
5753 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
Home
Features
News
Forums
Classifieds
Links
Downloads
Extras
OS4 Zone
IRC Network
AmigaWorld Radio
Newsfeed
Top Members
Amiga Dealers
Information
About Us
FAQs
Advertise
Polls
Terms of Service
Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
43 crawler(s) on-line.
 27 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!
 evilFrog:  9 mins ago
 MEGA_RJ_MICAL:  10 mins ago
 BigD:  11 mins ago
 Lou:  13 mins ago
 CygnusEd:  22 mins ago
 DiskDoctor:  36 mins ago
 Hypex:  39 mins ago
 matthey:  53 mins ago
 _Steve_:  1 hr 11 mins ago
 Dege:  1 hr 18 mins ago

Features

Main »» Tutorials

Spot's Porting for Dummies 1.0  Popular
(Read 2880 times)
SPOT'S PORTING FOR DUMMIES 1.0
==============================


INDEX
=====

00) Why should I read this? I can't code!
01) How to run a configure script
02) Common errors that occur when configuring
03) Converting unix path's to Amiga path's
04) Defines
05) Understanding error messages
06) Common errors
07) Tips and trix
08) Creating a Makefile by hand
09) Help me!
10) Contact me
11) Thanks to...

00) WHY SHOULD I READ THIS? I CAN'T CODE!

Well, the sad fact is that, neither can I! :) I am just a stubborn geezer!
And look at me now... 100+ uploads to http://os4depot.net compiling
multiplatform stuff for AmigaOS 4.0 isn't THAT hard, c'mon! If I can do it,
you can do it too! You'll jump up and down screaming when you managed to
compile your first SDL app, I did! To my defence I have to say that I had
to figure out a lot of the process the hard way! :P
/Spot


01) HOW TO RUN A CONFIGURE SCRIPT
=================================

FOR NEWLIB
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/newlib/lib --includedir=/SDK/Local/common/include CFLAGS=-mcrt=newlib CPPFLAGS="-mcrt=newlib -DMINIGL" CXXFLAGS=-mcrt=newlib LIBS=-lunix LDFLAGS=-mcrt=newlib

Use the same line if you are going to compile a linklibrary, but if you want to
compile exclusively for newlib or clib2 change /common/ to clib2 or newlib.

FOR CLIB2
If you want to configure for CLIB2, first fix the PATH, start ABC-Shell by
typing 'sh' in Amiga-Shell and then type; PATH=/SDK/Local/clib2/bin:$PATH

./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib --includedir=/SDK/Local/common/include CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL" CXXFLAGS=-mcrt=clib2 LIBS=-lunix LDFLAGS=-mcrt=clib2

Use the same line if you are going to compile a linklibrary, but if you want to
compile exclusively for newlib or clib2 change /common/ to clib2 or newlib.

FOR CYGNIX
CFLAGS="-O2 -mcrt=clib2 -I/usr/X11R6.3/includeinclude -I/usr/include" LDFLAGS="-L/usr/X11R6.3/lib -laos4util -L/usr/lib -lunix -lnet -lamiga -lm -lauto" CPPFLAGS="-O2 -I/usr/X11R6.3/include -I/usr/local/include -I/usr/include" LIBS="-L/usr/X11R6.3/lib -laos4util -L/usr/local/lib -L/usr/lib -lunix -lnet -lm -lamiga -lauto" ./configure


TRICKY CONFIGURES
Some configure scripts just don't want to do what you want them to, here's some real world examples,
from when I have had to tweak a configure script by issuing some flags;

Xmoto configured without Automake (notice the amigaos path fix at the end);
./configure CFLAGS=-DMINIGL CXXFLAGS=-DMINIGL SDL_CFLAGS=-DMINIGL CC=g++ CXX=g++ LIBS="-lGL -lGLU -llua -lode -lSDL_image -lSDL_mixer -lsmpeg -lvorbisfile -lvorbisenc -lvorbis -logg -lft2 -lpng -ljpeg -lz -lSDL -lpthread -lunix -lcurl -lauto" --with-sdl-prefix=/sdk/local/clib2/ --disable-dependency-tracking --srcdir=/Bob/Coding/xmoto-0.2.0 --prefix=/PROGDIR/ --datadir=data

And some manual changes to the Xmoto Makefile;
remove: $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) ... from LINK
remove: $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) ... from CXXLINK

libXML:
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib --includedir=/SDK/Local/common/include CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -DLIBXML_DOTTED_VERSION=2.6.26 -DLIBXML_TEST_VERSION=20626 -DLIBXML_VERSION=20626 -DLIBXML_VERSION_STRING=20626" CXXFLAGS=-mcrt=clib2 LIBS=-lunix LDFLAGS=-mcrt=clib2



02) COMMON ERRORS THAT CAN OCCUR WHEN CONFIGURING
=================================================

I get errors like this;
configure: warning: CFLAGS=-mcrt=newlib: invalid host type

Why?
The configure script is probably old, don't worry, we can still use it,
but we have to issue the commands a little bit differently. Here's how;

FOR NEWLIB
CC=gcc CFLAGS=-mcrt=newlib CPPFLAGS="-mcrt=newlib -DMINIGL" CXXFLAGS=-mcrt=newlib LIBS=-lunix LDFLAGS=-mcrt=newlib ./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/newlib/lib --includedir=/SDK/Local/common/include

FOR CLIB2
CC=gcc CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL" CXXFLAGS=-mcrt=clib2 LIBS=-lunix LDFLAGS=-mcrt=clib2 ./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib --includedir=/SDK/Local/common/include


I get errors like this;
configure: error: C compiler cannot create executables

Why?
AmigaOS doesn't support the -pipe and -s flags.
Remove the -pipe and -s flags from the configure script. (The file called 'Configure').


I get errors like this;
checking for IMG_Load in -lSDL_image... no

Why?
We are linking with static libraries, and we need to be tell exactly what
to link in. Locate this line in the configure script;

LIBS="-lSDL_image $LIBS"

SDL_image depends on some more libraries to function correctly,
add them like this;

LIBS="-lSDL_image -lpng -lpng -lz $LIBS"


I get errors like this;
checking for Mix_OpenAudio in -lSDL_mixer... no

Why?
We are linking with static libraries, and we need to tell exactly what
to link in. Locate this line in the configure script;

LIBS="-lSDL_mixer $LIBS"

SDL_mixer depends on some more libraries to function correctly,
add them like this;

LIBS="-lSDL_mixer -lvorbisfile -lvorbis -logg $LIBS"


The same thing also often happens when configure is searching for
SDL_ttf, and you know why by now. We need to specify some more libs that
SDL_ttf depends on. It needs -lfreetype and -lz. I will leave the
rest to you as an excersize.


If you have added the needed dependecies to the configure script, and
it still doesn't work it can be due missing files in the SDK.
freetype-config and smpeg-config are missing in the archives available
on http://www.os4depot.net. I compiled my libs by myself to get the
missing files, but hopefully the authors of the AmigaOS 4.0 versions
will notice and fix these issues.

Another common problem are wrong paths in the .la files found in
SDK:Local/newlib/lib or SDK:Local/clib2/lib.
Check your .la files to see if they are configured correctly, locate
the following lines;

# Directory that this library needs to be installed in:
libdir='/SDK/Local/newlib/lib'

This one is set up correctly, notice libdir='/SDK/Local...'
if it's set to '/USR/Local...' it's wrong.

If it still doesn't work, and you are sure that you have the library
installed, try to remove the whole section where it checks
for the failing library in the configure file.
This is not recommended, but if there is no other way...


Now you should be ready to build your project. When porting unix apps
always type GMAKE.
MAKE is for Amiga projects only.



03) CONVERTING UNIX PATH'S TO AMIGA PATHS
=========================================


How do I convert UNIX paths into AmigaDOS paths?

Exchange getenv("HOME"); to "PROGDIR:"

Examples;
org: strcpy(path, getenv("HOME"));
new: strcpy(path, "PROGDIR:");

org: strcpy(home,getenv("HOME"));
new: strcpy(home,"PROGDIR:");

Paths to datadirs are often set during the configure process by issuing
-DDATADIR= if this is the case set it to -DDATADIR=/PROGDIR/
It's also common that the datadir are set in the makefiles locate DATADIR=
and change it to DATADIR=/PROGDIR/


04) DEFINES
===========

Defines are often set in config.h, if something is configured wrongly, you can
often change it here by using #DEFINE and #UNDEF.

Here's a define example, that considers BeOS and AmigaOS 4.0;

#if !defined(__BEOS__) && !defined(__amigaos4__)

and here's one that considers all AmigaOS flavours;

#ifdef __AMIGA__
blah blah blah
#else
blah blah blah
#endif


05) UNDERSTANDING ERROR MESSAGES
================================

Error:
No return statement in function returning non-void

What does it really mean?
There is no return in a function that needs a return.


Error:
Control reaches end of non-void function

What does it really mean?
it is reaching the end of a function that needs a return, but there is no return.

Error:
May be used uninitialized in this function

What does it really mean?
The variable is not initialized.

Error:
Warning: implicit declaration of function 'blah blah'

What does it really mean?
You need to include a header.


06) COMMON ERRORS
=================

warning: incompatible implicit declaration of built-in function 'exit'
warning: incompatible implicit declaration of built-in function 'abort'
solution: #include

warning: implicit declaration of function 'strlen'
warning: incompatible implicit declaration of built-in function 'strlen'
solution: #include

warning: implicit declaration of function 'memcpy'
warning: incompatible implicit declaration of built-in function 'memcpy'
solution: #include

error: memory.h: No such file or directory
solution: #include

error: malloc.h: No such file or directory
solution: #include


07) TIPS AND TRIX
=================

How do I search for text strings using GREP?
From ABC-Shell type;
grep -R "I am looking for this" *


How do I make a DIFF file with my changes?
From ABC-Shell type;
diff originalfile.cpp mychangedfile.cpp >./originalfile.patch


My executeable is crashing, how do I debug it?
I the Grim Reaper, click generate stack trace under the Stack Trace tab.
Now you'll see a lot of numbers and things.

Now use addr2line to find out where in the source the crash occured.

Here's an example;
addr2line -e xmoto.exe 0x39c48


How do I use Python?
Assign python: to your python dir, and then add it to your path from
abc-shell: PATH=$PATH:/python



08) CREATING A MAKEFILE BY HAND
===============================

AN EXAMPLE MAKEFILE
this makefile could be used if the build system is a mess and you want to
simplify it a bit, alter it to fit your needs.

CC = gcc
CPP = g++
RM = rm
STRIP = strip
CFLAGS = -mcrt=newlib -Wall -O2 -I/sdk/local/newlib/include/SDL -I/sdk/local/common/include/SDL
LDFLAGS = -mcrt=newlib -lSDL_gfx -lSDL_net -lSDL_image -lpng -ljpeg -lz -lSDL_mixer -lvorbisfile -lvorbis -logg -lSDL_ttf -lfreetype -lz -lsdlmain -lsdl -lauto -lpthread -lm -lunix
OBJS = hangman.o sound.o logo.o gfx.o pointer.o ShiftyEngine.o dict.o
OUTPUT = hangman

all: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(OUTPUT)

main.o: main.cpp ShiftyEngine.h
$(CPP) ${CFLAGS} -c hangman.c


09) HELP ME!
============

I created this document mainly to aid myself from the beginning, but it turned
out to be quite useful in the end, so I decided to clean it up and release it.
I'd love to get help extending this document, if you've spotted an error, want to
clarify a section or add a new section, please join me in my mission! I am sure
it will be appreciated by many! --- And hey! What could happen? os4depot could be
flooded by new files? That wouldn't be so bad would it?


10) CONTACT ME
==============

Send a mail to: spot AT triad DOT se
You can also find me and a bunch of other helpful developers in #amigaworld on irc.amigaworld.net

11) THANKS TO
=============

This wouldn't be possible without:

HNL_DK, NICOMEN, ITIX, ZEROHERO, ITIX, and BLACKY_STARDUST and the rest in #amigadev!
THANX A LOT GUYS!
- spotUP
[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle