|
| |
| |
| |
|
|
|
Online members:
regan 3 min(s) ago
20 guests are online.
You are an Anonymous user. You can register for free by clicking here. |
|
|
| |
| |
| |
| |
| |
| |
UtilityBase needs your
help!
Spot's Porting Guide for Dummies 1.6.1 [UPDATED] by Spot / Up Rough Link: Spot's Porting Guide for Dummies 1.6.1 [UPDATED] (txt)
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... 300+ 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
hnl_dk: Updated to version 1.1
SPOT'S PORTING FOR DUMMIES 1.6.1
================================
INDEX
=====
00) Quick Reference
01) Why should I read this? I can't code!
02) History
03) What to port
04) Getting the SDK up to date
 -Essentials
 -Languages
 -Misc
 -Misc Linklibs
05) The basics
06) How to configure
 -For newlib
 -For clib
 -For cygnix
 -Configuring a link library
 -Tricky configures
 -A small hint
 -Explanation of some GCC flags
07) Common errors that occur when configuring
08) Converting unix path's to Amiga path's
09) Defines
10) Understanding error messages
11) Common errors
12) Tips and tricks
13) Creating a Makefile by hand
14) Creating a GUI using Emperor (Alpha!)
15) Help me!
16) Contact me
17) Thanks
00) QUICK REFERENCE
===================
For lazy geezers like me, I use these lines a lot and I don't want to
wade through the guide to find them all the time, if you are new to this
guide, just skip this chapter for now.
Allegro
g++ -mcrt=newlib -Wall -O2 -Wno-deprecated-declarations -I/sdk/local/newlib/include/allegro -I/sdk/local/newlib/include/ -I/sdk/local/common/include/ -c *.cpp
g++ -mcrt=newlib -Wall -O2 *.o -lalmp3 -laldumb -lalfont -lalfblend -lagup -lallegro -lpthread -lstdc++ -lauto -lunix -o test
NEWLIB
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/newlib/lib CFLAGS=-mcrt=newlib CPPFLAGS="-mcrt=newlib -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=newlib LIBS="-lauto -lunix" LDFLAGS=-mcrt=newlib
NEWLIB OLD
CC=gcc CFLAGS=-mcrt=newlib CPPFLAGS="-mcrt=newlib -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=newlib LIBS="-lauto -lunix" LDFLAGS=-mcrt=newlib ./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/newlib/lib
CLIB2 (type PATH=/SDK/Local/clib2/bin:$PATH from ABC-Shell first!)
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS="-lauto -lunix" LDFLAGS=-mcrt=clib2
CLIB2 OLD (type PATH=/SDK/Local/clib2/bin:$PATH from ABC-Shell first!)
CC=gcc CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS="-lauto -lunix" LDFLAGS=-mcrt=clib2 ./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib
LinkLib NEWLIB /common/
./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 -D__USE_INLINE__" CXXFLAGS=-mcrt=newlib LIBS=-lauto LDFLAGS=-mcrt=newlib
LinkLib CLIB2 /common/ (type PATH=/SDK/Local/clib2/bin:$PATH from ABC-Shell first!)
./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 -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS=-lauto LDFLAGS=-mcrt=clib2
LinkLib CLIB2 /clib2/ (use this one if you want to make a clib2 only version) (type PATH=/SDK/Local/clib2/bin:$PATH from ABC-Shell first!)
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib --includedir=/SDK/Local/clib2/include CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS=-lauto LDFLAGS=-mcrt=clib2
LinkLib CLIB2 OLD /common/ (type PATH=/SDK/Local/clib2/bin:$PATH from ABC-Shell first!)
CC=gcc CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS="-lauto -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
01) 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
02) HISTORY
===========
Version 1.6.1
Misc small changes and additional info 'backported' from the AROS 'port'
of this guide.
Version 1.6.0
Added a guide on how to make GUI's using Emperor.
Added lots of small things that I can't remember.
Version 1.5.3
Added a tip on Fullscreen modes in SDL apps/games. Thanks Lio.
Added some quick references related to Allegro compiling. Woooot? Already? ;)
Version 1.5.2
Corrected some small things related to SDL_Mixer
Version 1.5.1
Added SVN to tips and tricks
Version 1.5
Fixed a typo. I had writen -lpng -lpng, when it should be -lpng -ljpeg.
Thanx to Raziel for the report.
Added a new chapter: History
Added a new chapter: Getting your SDK up to date
Added a new chapter: The basics
Added a new chapter: Configuring linklibs
Added a new chapter: Quick Reference
Added more common errors
Defines section updated
Common errors section updated
Corrections to the configure lines. Thanx HNL!
Corrections to the example makefile. Thanx Booger!
A lot of small changes that I can't remember.
Corrected the cygnix config line.
03) What to port?
=================
Look what additional packages are required for the software you want to port.
You cannot simply port when GUI toolkits like GTK or QT are needed.
Only software which runs under a console can be ported directly.
When you want to port games, look if they use libSDL.
Avoid software which requires OpenGL.
04) GETTING THE SDK UP TO DATE
==============================
Lots of parts of the SDK have been updated since the last official
release, so install the following libs to get an up to date SDK.
This is especially important for the SDL libs, as the ones included
in the SDK are buggy.
ESSENTIALS
ABC-Shell - Amiga Bourne Compatible Shell
http://www.os4depot.net/share/development/utility/abc-shell.lha
GNU make including parallel compile
http://www.os4depot.net/share/development/utility/make-bin.lha
Diffutils - file comparison tools
http://www.os4depot.net/share/development/utility/diffutils-hnl.lha
m4 - Unix macro processor
http://www.os4depot.net/share/development/misc/m4.lha
GNU core utilities
http://www.os4depot.net/share/development/utility/coreutils-bin.lha
Texinfo - GNU documentation system
http://www.os4depot.net/share/development/misc/texinfo-bin.lha
clib2
http://sourceforge.net/project/showfiles.php?group_id=115224
LANGUAGES
Free Pascal Compiler
http://os4depot.net/share/development/language/fpc.lha
Perl 5.8.5
http://www.os4depot.net/share/development/language/perl.tar.bz2
Lua - powerful embeddable programming language
http://os4depot.net/share/development/language/lua.lha
MISC
Boost C++ libraries
http://os4depot.net/share/development/library/boost.lha
Expat C library for parsing XML
http://os4depot.net/share/development/library/expat-ppc.lha
GNU termcap library
http://os4depot.net/share/development/library/termcap.lha
MISC LINKLIBS
LibCurl - the multiprotocol file transfer library
http://os4depot.net/share/development/library/libcurl.lha
libFreetype2
http://www.os4depot.net/share/library/misc/freetype2.lha
libJPEG
http://www.rcdrummond.net/amiga/libjpeg-6b.lha
libODE - ODE and Opcode
http://os4depot.net/share/development/library/ode.tgz
libOGG
http://www.rcdrummond.net/amiga/libogg-1.1.lha
libOpenSSL - OpenSSL: The Open Source toolkit for SSL/TLS
http://os4depot.net/share/development/library/libopenssl.lha
libPNG
http://www.rcdrummond.net/amiga/libpng-1.2.6.lha
libSDL_gfx
http://os4depot.net/share/development/library/sdl_gfx.lha
libSDL_perl
http://os4depot.net/share/development/library/sdl_perl.tar.bz2
libSDL_ttf and libSDL_net
http://os4depot.net/share/development/library/sdl_ttf_net.lha
libVorbis
http://www.rcdrummond.net/amiga/libvorbis-1.0.1.lha
libXML2 - The XML C parser and toolkit of Gnome
http://os4depot.net/share/development/library/libxml2.lha
zlib
http://www.rcdrummond.net/amiga/zlib-1.2.1.lha
05) THE BASICS
==============
The first thing you do is to check how to build your project.
If there is a file called configure in the root directory of the archive, it means
you'll have to configure it for your platform.
Start ABC-Shell by typing 'sh' in your shell, and configure it. See the next
chapter for a description on how to do that.
After the project is properly configured it's time to roll out the compiler.
Start building your project by typing GMAKE.
However, if there was no file called Configure, look for a file called
Makefile. Edit it to suit AmigaOS 4.0 and build the project with GMAKE.
If everything compiled and linked you are ready to test your port. A very common
problem is that it won't find it's datafiles, and crash. Fix the path's as
described in the path-fixing chapter, and try to run it again.
If you've compiled a link library a 'GMAKE INSTALL' is recommended, as it will
copy all neeeded files to the right places.
OK, you're done now, upload it to os4depot and aminet!
06) HOW TO CONFIGURE
====================
FOR NEWLIB
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/newlib/lib CFLAGS=-mcrt=newlib CPPFLAGS="-mcrt=newlib -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=newlib LIBS="-lauto -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 CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS="-lauto -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/include/ -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
CONFIGURING A LINK LIBRARY
When configuring a linklib we need an extra option, --includedir=
this is to specify where to install the header files. Use /common/ if you are
going to compile the linklib for both clib2 and newlib. Change it to /newlib/ or /clib2/ if you
are going to compile for just one of them. It's recommended to make versions for both when
possible. Here's the example configure lines;
NEWLIB with headers in .../common/include/ (Use this if you intend to compile for both newlib and clib2.)
./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=-lauto LDFLAGS=-mcrt=newlib
NEWLIB with headers in .../newlib/include/ (Use this if you intend to compile for newlib only.)
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/newlib/lib --includedir=/SDK/Local/newlib/include CFLAGS=-mcrt=newlib CPPFLAGS="-mcrt=newlib -DMINIGL" CXXFLAGS=-mcrt=newlib LIBS=-lauto LDFLAGS=-mcrt=newlib
CLIB2 with headers in .../common/include/ (Use this if you intend to compile for both clib2 and newlib.)
./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=-lauto LDFLAGS=-mcrt=clib2
CLIB2 with headers in .../clib2/include/ (Use this if you intend to compile for clib2 only.)
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib --includedir=/SDK/Local/clib2/include CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL" CXXFLAGS=-mcrt=clib2 LIBS=-lauto LDFLAGS=-mcrt=clib2
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: --srcdir=/Scene/Coding/xmoto-0.2.4);
./configure --disable-dependency-tracking --srcdir=/Scene/Coding/xmoto-0.2.4 --datadir=/PROGDIR/ --bindir=/SDK/Local/C --prefix=/PROGDIR/ CFLAGS=-mcrt=clib2 CXXFLAGS="-mcrt=clib2 -DMINIGL" LIBS="-mcrt=clib2 -lGL -lGLU -llua -lode -lSDL_gfx -lSDL_net -lSDL_image -lpng -ljpeg -lz -lSDL_mixer -lsmpeg -lm -lvorbisfile -lvorbis -logg -lstdc++ -lSDL_ttf -lfreetype -lz -lsdlmain -lsdl -lauto -lpthread -lm -lunix" --with-sdl-prefix=/sdk/local/clib2
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 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
GNGEO: Notice the UNIX path fix at the end (pkgdatadir=/PROGDIR/data)
./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS="-lauto -lunix" LDFLAGS=-mcrt=clib2 pkgdatadir=/PROGDIR/data
A SMALL HINT
It makes sense to write the configure statement to a text file.
This way we can easily re-run it like this 'sh mybuildscript.sh'
But before we re-run the script we have to do 'gmake distclean' or 'rm -f config.cache' (the unix way)
or simply 'delete config.cache' (the Amiga way) in order to reset the configuration process.
EXPLANATION OF SOME GCC FLAGS
LDLAGS="-lunix"
This enables Linux semantics for paths. Linux applications often use absolute paths to their data files.
But an absolute Linux path like /usr/local/app means for AmigaOS to go one level up, then go into the usr directory.
--prefix=/PROGDIR
Prefixes all paths with /PROGDIR. Together with the -lunix option this allows to use Linux paths during compiling and
AmigaOS paths when running the exe.
07) COMMON ERRORS THAT CAN OCCUR WHEN CONFIGURING
=================================================
I get errors like this;
configure: warning: CFLAGS=-mcrt=newlib: invalid host type
Solution;
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 -D__USE_INLINE__" CXXFLAGS=-mcrt=newlib LIBS="-lauto -lunix" LDFLAGS=-mcrt=newlib ./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/newlib/lib
FOR CLIB2
CC=gcc CFLAGS=-mcrt=clib2 CPPFLAGS="-mcrt=clib2 -DMINIGL -D__USE_INLINE__" CXXFLAGS=-mcrt=clib2 LIBS="-lauto -lunix" LDFLAGS=-mcrt=clib2 ./configure --disable-dependency-tracking --bindir=/SDK/Local/C --prefix=/SDK/Local --libdir=/SDK/Local/clib2/lib
I get errors like this;
configure: error: C compiler cannot create executables
Solution;
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
Solution;
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 -ljpeg -lz $LIBS"
I get errors like this;
checking for Mix_OpenAudio in -lSDL_mixer... no
Solution;
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 -lsmpeg -lm -lvorbisfile -lvorbis -logg -lstdc++ $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 dependencies 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.
08) 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/");
old: sprintf(rc_dir, "%s/.gngeo/romrc.d", getenv("HOME")); new: sprintf(rc_dir, "%sgngeo/romrc.d", "/PROGDIR/");
Notice that I removed "/." in the last example.
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/
09) DEFINES
===========
Defines are often set in config.h, if something is configured wrongly, you can
often change it here by using #DEFINE and #UNDEF.
A define example that considers all AmigaOS flavours;
#ifdef __AMIGA__ blah blah blah #else blah blah blah #endif
A define example that only considers AmigaOS 4.0;
#ifdef __amigaos4__ blah blah blah #else blah blah blah #endif
A define example, that considers BeOS and AmigaOS 4.0;
#if !defined(__BEOS__) && !defined(__amigaos4__)
An example of a more complex #ifdef
#ifdef GP2X char *gngeo_dir="save/"; #elif defined __amiga__ char *gngeo_dir="/PROGDIR/save/"; #else char *gngeo_dir=get_gngeo_dir(); #endif
10) 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.
11) COMMON ERRORS
=================
warning: incompatible implicit declaration of built-in function 'exit'
warning: incompatible implicit declaration of built-in function 'abort'
solution: #include <stdlib.h>
warning: implicit declaration of function 'strlen'
warning: incompatible implicit declaration of built-in function 'strlen'
solution: #include <string.h>
warning: implicit declaration of function 'memcpy'
warning: incompatible implicit declaration of built-in function 'memcpy'
solution: #include <string.h>
error: memory.h: No such file or directory
solution: #include <string.h>
error: malloc.h: No such file or directory
solution: #include <stdlib.h>
warning: incompatible implicit declaration of built-in function 'printf'
solution: #include <stdio.h>
warning: implicit declaration of function 'srandom'
warning: implicit declaration of function 'random'
solution:
We don't have random() and srandom() in neither clib2 or newlib.
You "could" use rand() and srand() instead they are not totally compatible,
but it should work.
One way to do it is to manually edit the sources and replac srandom and random
with srand and rand. Another way to do it is to; #define srandom srand in the
source.
warning: implicit declaration of function 'MyRemove'
solution: #define MyRemove Remove
error: 'sqrtl' was not declared in this scope
solution: #define sqrtl    sqrt
Fullscreen modes doesn't work in your newly ported SDL game?
solution: try replacing SDL_HWSURFACE with SDL_SWSURFACE.
12) TIPS AND TRICKS
===================
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?
You can use Snoopy to find out what your application tries to do.
It's VERY common that the app doesn't find a file that it needs.
Check the section about fixing UNIX path's to fix it.
In 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
How do I redirect GCC warnings and errors to a text file?
gmake 2>/ram/warnings.txt
How do I make a tar.gz archive out of my source dir?
tar czvf myarchive.tar.gz mysources/
How do I fetch a source when all I have is an URL like this one? svn://svn.72dpiarmy.com/smw
install Subversion aka SVN and type this in shell;
svn checkout svn://svn.72dpiarmy.com/smw
How do I redirect GCC warnings and errors to a text file?
gmake 2>warnings.txt
13) 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.
Usually you only need to modify an existing makefile, and add -mcrt=newlib or
-mcrt=clib2, add these include paths;
-I/sdk/local/newlib/include/SDL -I/sdk/local/common/include/SDL
and add some linklibraries.
Here's an explanation of what the flags does.
CC  - the name of the C compiler executeable
CXX - the name of the C++ compiler executeable
RM  - the name of the delete command
STRIP - the name of the strip command (used to remove debug data from exe files)
CFLAGS - tells the compiler where to find the includes and what clib to use etc.
     specify -mcrt=newlib or -mcrt=clib2 here.
LDFLAGS - tells the compiler what link libraries to include etc.
     specify -mcrt=newlib or -mcrt=clib2 here too, aswell as the other needed
     linklibs depending on what you are compiling.
OBJS - The compiler (GCC/G++) compiles object files (#?.o) from your .C or .CPP
     files that are later linked together to become an exe file.
     Specify the object file names here.
OUTPUT - The name of the final exe file.
---cut-here--------------------------------------------------------------------
CC  = gcc -mcrt=newlib
CXX = g++ -mcrt=newlib
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 -lsmpeg -lm -lvorbisfile -lvorbis -logg -lstdc++ -lSDL_ttf -lfreetype -lz -lsdlmain -lsdl -lauto -lpthread -lm -lunix
OBJS = a.o b.o c.o
OUTPUT = test.exe
all: $(OBJS)
$(CXX) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(OUTPUT)
main.o: main.cpp main.h
$(CXX) $(CFLAGS) -c main.cpp
---cut-here--------------------------------------------------------------------
14) CREATING A GUI USING EMPEROR (ALPHA!)
=========================================
This section of the guide is to be considered alpha, it's untested,
and the guide was given to me in a hurry in #amigadev by Ami603.
Open your project and go to the Variables page.
Open the edit window by clicking the 'edit' button.
Add a stringpointer called commandfile. do not add any values to it.
Step by Step:
Go to the request page
Step by step;
page variable, click on edit, select stringpointer, name commandfile, click add.
Return back to the reaction page.
Go to the requester page.
Open the edit window again if it's not opened.
Select errorrequest.
Type "your emulator executable doesn't exists" or something similar as BodyText, and add it.
Select errorrequest again.
Type "The file you selected does not exist" as BodyText, and add it.
Go to the reaction page.
Click twice on your added getfile gadget (on the left).
A text editor will be opened with a function called GetFileX_GadgetUP_evt.
Enter this code between the brackets;
IIntuition->IDoMethod((Object *)gad[GID_Getfile1],GFILE_REQUEST,NULL,win[WID_Window1],NULL,TAG_DONE);
IIntuition->GetAttrs(gad[GID_Getfile1],GETFILE_FullFile,&commandfile,TAG_DONE);
IIntuition->RefreshGadgets(gad[GID_Getfile1],win[WID_Window1],NULL);
(Assuming your gadget is called GetFile1 and you didn't edit the gadget name).
Close the editor, click twice on the launch button.
Another function will be displayed in the text editor, 'Button1_GadgetUP_Evt'
Enter this code between the brackets;
BPTR executable,file;
STRPTR commandbuffer;
if (!(executable = IDOS->Lock("here_goes_The_emulator_cli_executable_name",ACCESS_READ)))
{
// First requester below here
}
if (!(file = IDOS->Lock(commandfile,ACCESS_READ)))
{
// Second requester below here
}
else if ((executable)&&(file))
{
commandbuffer = IUtility->ASPrintf("here_goes_the_emulator_cli_executable_name \"%s\"",commandfile);
if (IDOS->SystemTags(commandbuffer,
  SYS_Input, NULL,
  SYS_Output, NULL,
  SYS_Asynch, TRUE,
  TAG_END)==-1)
{
 IDOS->Printf("Commandline: %s failed\n",commandbuffer);
}
IExec->FreeVec(commandbuffer);
}
IDOS->UnLock(executable);
IDOS->UnLock(file);
Now without closing the texteditor go to the requester page again and put your
editor cursor below the "//first requester below here", click twice on the
ErrorRequester1 same for "//Second requester below here",
click twice on ErrorRequester2, close the editor, save all, shell ->make
Try to edit the your_command_cli_executable with the name of your exe in both places
in this function.
You can add a third requester, with your about info inside, add another button and
do the same as before click button twice, select function, go to requesters page
and click twice on it.
15) 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?
16) CONTACT ME
==============
Send a mail to: spot AT triad DOT se
You can also find me and a bunch of other helpful developers in #amigadev on irc.amigaworld.net
17) THANKS
==========
This wouldn't be possible without:
HNL_DK, NICOMEN, ITIX, ZEROHERO, VARTHALL and BLACKY_STARDUST, AMI603, LIO and the rest in #amigadev!
THANX A LOT GUYS!
  .___________________________________________________________.
  |                            |
  |      G U I D E W R I T TE N B Y      |
 ._______                   .______. |
 | ____/________________________________________|  |__ .
._|____._   |  ._  |  ._  |  _/______.
|  |/   |  |/  |  |/  |  |/  |
|       |  _________|      |      |
|_________________|______|spt/up |_______________|_______________|
  .                            .
  |                            |
  | I am in a shitty economical situation, so if you feel |
  | that what I do is worth anything, use paypal to donate |
  |   to my email addy, spotATtriadDOTse, thanx!   |
  |                            |
  |         Spot / Up Rough 2007        |
  |___________________________________________________________|
|
|
| Last poster |
Message |
|
Posted: 2006-Nov-8 18:39:06
The #include files do not appear in this document.  Is it possible to use < and > ? |
|
Posted: 2006-Nov-8 19:58:41
Sure or just [ csource ] [ /csource ]:
|
|
Posted: 2007-Jul-27 11:23:06
Just a minor correction:
"A define example, that considers BeOS and AmigaOS 4.0;
#if !defined(__BEOS__) && !defined(__amigaos4__)"
That will execute the code as long as it's not BEOS/OS4.
To execute the code if you have activated BeOS or OS4 support it should be:
"#if defined(__BEOS__) || defined(__amigaos4__)"
BTW, people who crosscompile usually adds:
--target=ppc-amigaos
to the ./configure line.
Sometimes you may have to add --host=i686-cygwin or i686-linux if the makefile executes its own programs that must be run on the host platform. |
|
Posted: 2007-Nov-29 04:30:29
What if I remove all the -s flags (test -s, make -s) and it still says compiler cannot create executables? Not uncommon. |
|
Posted: 2007-Nov-30 05:34:38
check if there are any signs of -pipe anywhere in the makefile. |
|
|
|