Definitive way to set up DCdev in Linux?
-
- DCEmu Fast Newbie
- Posts: 20
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu Feb 03, 2005 1:59 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Definitive way to set up DCdev in Linux?
Prythee,
I've been looking high and low for the most recent version of a build script or guide that would help me set up GCC, newlib & KOS (etc.) in order to compile DC code on my Linux machine. I found several but they either refer to old versions of GCC & KOS or give me weird errors. If somebody could point me to some up-to-date instructions (if any) I would really appreciate it
I've been looking high and low for the most recent version of a build script or guide that would help me set up GCC, newlib & KOS (etc.) in order to compile DC code on my Linux machine. I found several but they either refer to old versions of GCC & KOS or give me weird errors. If somebody could point me to some up-to-date instructions (if any) I would really appreciate it
I am not really from outer space.
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
WARNING - This guide is out of date. For a more up-to-date guide, see henzenmann's posts in this topic.
Assuming you want the newest set of compilers, and the newest KOS (with full C and C++ support and so on), then you'll want to use Jim Ursetto's makefile. It'll automatically download the required source code, build binutils, GCC, newlib, and g++. The only catch is that's it's a bit out of date, and requires some tweaking to get it to work on the latest versions of KOS (mostly, removing the patches required to get it working on earlier versions of KOS, since they're no longer required).
http://3e8.org/hacks/dc/dc-chain-0.1.tgz
I can't remember the exact instructions for building it at the moment. I'll get back to you on that.
One catch - the ARM compiler that this makefile builds doesn't generate working code, so it's kind of useless, and you'd have to revert to an older version (GCC 3.0.4) if you want it. You may as well not bother building it - current KOS snapshots include a pre-compiled version of the sound driver, which is the only part that actually needs the ARM compiler. Unless you want to write your own sound driver, you should be fine with that.
Oh yeah, you also need development libraries for zlib, libpng and libjpeg, and you might need to hack some of the makefiles in the KOS utils directory to get them to build (I had to add -lz to a couple of them)
Edit: My mistake - it doesn't download stuff for you. Oopsie...
Anyway, here's how you do it. I think. I haven't tested this in a while...
First off, you need to grab dc-build (above), the source code for Binutils 2.15, GCC 3.4.3 (core and g++), Newlib 1.12.0, and the newest KOS snapshot (kos, kos-ports).
Untar dc-chain-0.1.tgz. That'll give you a directory called dc-chain-0.1
Now, unpack binutils, newlib, and gcc (both files) into that directory. Unpack kos and kos-ports somewhere else (anywhere else - doesn't really matter - but extract them to the same directory). You should end up with a directory structure like this:
Got something that resembles that? Good.
Go into the patches directory and delete everything except gcc-3.4.1.diff and newlib-1.12.0-kos.diff.
Rename gcc-3.4.1.diff -> gcc-3.4.3.diff and open it in a text editor. Replace all instances of "3.4.1" with "3.4.3". Not sure if that's absolutely required (shouldn't be), but it couldn't hurt...
Open the Makefile. Edit these lines to tell it where you want to put the compiler, and where you have KOS installed (it wants the path to the kos directory, which was created when you unpacked the kos snapshot). I usually put the compiler in my home directory somewhere - that way, I don't need root access to install it, and I can get rid of it by simply deleting the thing.
Also, change the version of GCC:
to:
Now, to build the toolchain. Pull up a terminal, go to the dc-build-0.1 directory, and do this:
If that didn't work, panic. If it worked, great.
Edit: Now you should build GCC 3.0.4 for the ARM sound CPU. See below for details.
On to KOS.
First, you need to create an appropriate environment file. Go to kos/doc, and look for environ.sh.sample. Copy it to kos/environ.sh, and open it in a text editor. Edit it to your requirements. You'll want to change KOS_BASE, KOS_LOADER (maybe), KOS_CC_BASE (wherever you installed the SH-4 compiler to), DC_ARM_BASE (wherever you installed the ARM compiler to) and maybe something else. Read it and see.
Open environ_dreamcast.sh, and after "-fno-optimize-sibling-calls" add "-fno-crossjumping".
Pull up a terminal, change to the KOS directory, and do this:
That prepares the environment for compiling stuff with KOS. Now, to build KOS itself...
If all goes well, it should finish without errors. You might have some failures in the utils directory, usually you just need to add some libraries (-lz or -lm usually) into the Makefile, and it'll work.
Next, go to kos-ports, and type make. It should build the addon libraries, and they should also build without errors. You might need to remove SDL (unless you want it, in which case you'll have to fix it) if it doesn't compile, but everything else should be OK.
You should be able to build most of the examples. Not all of them work, but most of them do. Just cd to the examples directory, and type make. Most of them should build correctly, and work properly when you run them.
Assuming you want the newest set of compilers, and the newest KOS (with full C and C++ support and so on), then you'll want to use Jim Ursetto's makefile. It'll automatically download the required source code, build binutils, GCC, newlib, and g++. The only catch is that's it's a bit out of date, and requires some tweaking to get it to work on the latest versions of KOS (mostly, removing the patches required to get it working on earlier versions of KOS, since they're no longer required).
http://3e8.org/hacks/dc/dc-chain-0.1.tgz
I can't remember the exact instructions for building it at the moment. I'll get back to you on that.
One catch - the ARM compiler that this makefile builds doesn't generate working code, so it's kind of useless, and you'd have to revert to an older version (GCC 3.0.4) if you want it. You may as well not bother building it - current KOS snapshots include a pre-compiled version of the sound driver, which is the only part that actually needs the ARM compiler. Unless you want to write your own sound driver, you should be fine with that.
Oh yeah, you also need development libraries for zlib, libpng and libjpeg, and you might need to hack some of the makefiles in the KOS utils directory to get them to build (I had to add -lz to a couple of them)
Edit: My mistake - it doesn't download stuff for you. Oopsie...
Anyway, here's how you do it. I think. I haven't tested this in a while...
First off, you need to grab dc-build (above), the source code for Binutils 2.15, GCC 3.4.3 (core and g++), Newlib 1.12.0, and the newest KOS snapshot (kos, kos-ports).
Untar dc-chain-0.1.tgz. That'll give you a directory called dc-chain-0.1
Now, unpack binutils, newlib, and gcc (both files) into that directory. Unpack kos and kos-ports somewhere else (anywhere else - doesn't really matter - but extract them to the same directory). You should end up with a directory structure like this:
Code: Select all
kos
kos-ports
dc-chain-0.1
00PATCHES
00README
binutils-2.15
Loads of crap
gcc-3.4.3
More crap
Makefile
newlib-1.12.0
Even more crap
patches
Patch files
Go into the patches directory and delete everything except gcc-3.4.1.diff and newlib-1.12.0-kos.diff.
Rename gcc-3.4.1.diff -> gcc-3.4.3.diff and open it in a text editor. Replace all instances of "3.4.1" with "3.4.3". Not sure if that's absolutely required (shouldn't be), but it couldn't hurt...
Open the Makefile. Edit these lines to tell it where you want to put the compiler, and where you have KOS installed (it wants the path to the kos directory, which was created when you unpacked the kos snapshot). I usually put the compiler in my home directory somewhere - that way, I don't need root access to install it, and I can get rid of it by simply deleting the thing.
Code: Select all
sh_prefix := /usr/local/dc/$(sh_target)
arm_prefix := /usr/local/dc/$(arm_target)
kos_root=/home/jim/dc/kos/kos-1.3.0
Code: Select all
gcc_ver=3.4.1
Code: Select all
gcc_ver=3.4.3
Code: Select all
make patch
make build-sh4
Edit: Now you should build GCC 3.0.4 for the ARM sound CPU. See below for details.
On to KOS.
First, you need to create an appropriate environment file. Go to kos/doc, and look for environ.sh.sample. Copy it to kos/environ.sh, and open it in a text editor. Edit it to your requirements. You'll want to change KOS_BASE, KOS_LOADER (maybe), KOS_CC_BASE (wherever you installed the SH-4 compiler to), DC_ARM_BASE (wherever you installed the ARM compiler to) and maybe something else. Read it and see.
Open environ_dreamcast.sh, and after "-fno-optimize-sibling-calls" add "-fno-crossjumping".
Pull up a terminal, change to the KOS directory, and do this:
Code: Select all
. ./environ.sh
Code: Select all
make
Next, go to kos-ports, and type make. It should build the addon libraries, and they should also build without errors. You might need to remove SDL (unless you want it, in which case you'll have to fix it) if it doesn't compile, but everything else should be OK.
You should be able to build most of the examples. Not all of them work, but most of them do. Just cd to the examples directory, and type make. Most of them should build correctly, and work properly when you run them.
Last edited by BlackAura on Sun Aug 13, 2006 9:18 pm, edited 2 times in total.
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
The Dreamcast has two separate processors - one Hitachi SH-4 (the main CPU), and one ARM7 (the sound CPU), therefore you need two compilers. The makefile will build GCC 3.4.3 for both SH-4 and ARM7, but GCC 3.4.3 generates incorrect code for the ARM7 in the Dreamcast. You need GCC 3.4.3 for the SH-4, and GCC 3.0.4 for the ARM7. The two compilers are completely separate from each other, so the version of one does not affect the other.
Basically, after you've run "make build-sh4", but before you try building KOS, you need to build an ARM7 toolchain as well.
First, you need the required source code. These are different versions than the SH-4 toolchain, so you'll need these too.
Binutils 2.11.2
GCC 3.0.4 (Core only - we don't need C++ support)
Put them in a directory somewhere, pull up a terminal, and cd to that directory.
Decide where you're going to put the ARM toolchain. I put mine in my home directory - ~/dreamcast/arm-elf (with the SH-4 toolchain in ~/dreamcast/sh-elf) but you can put yours wherever you like. At the command line, type this (replacing the path if you want):
Now, we build and install Binutils:
Then, we build and install GCC:
That should be it. As long as there were no errors, your ARM toolchain should be good to go. Then you can continue with building KOS.
I've also edited the instructions above so that KOS should build correctly.
Basically, after you've run "make build-sh4", but before you try building KOS, you need to build an ARM7 toolchain as well.
First, you need the required source code. These are different versions than the SH-4 toolchain, so you'll need these too.
Binutils 2.11.2
GCC 3.0.4 (Core only - we don't need C++ support)
Put them in a directory somewhere, pull up a terminal, and cd to that directory.
Decide where you're going to put the ARM toolchain. I put mine in my home directory - ~/dreamcast/arm-elf (with the SH-4 toolchain in ~/dreamcast/sh-elf) but you can put yours wherever you like. At the command line, type this (replacing the path if you want):
Code: Select all
PREFIX=~/dreamcast/arm-elf
Code: Select all
tar xzf binutils-2.11.2.tar.gz
mkdir binutils-arm-build
pushd binutils-arm-build
../binutils-2.11.2/configure --prefix=$PREFIX --target=arm-elf
make all install
popd
Code: Select all
tar xzf gcc-core-3.0.4.tar.gz
mkdir gcc-arm-build
pushd gcc-arm-build
../gcc-3.0.4/configure --prefix=$PREFIX --target=arm-elf --without-headers --with-newlib --enable-languages=c
make all install
popd
I've also edited the instructions above so that KOS should build correctly.
-
- DCEmu Fast Newbie
- Posts: 20
- Joined: Thu Feb 03, 2005 1:59 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Panic time - when i run "make patch" after having modified the makefile, it acts odd, here's part of the output:
patching file gcc/config.gcc
can't find file to patch at input line 51
perhaps you used the wrong -p or --strip options
The text leading up to this was:
<lots of crap involving diff on two files named "atomicity.h", one being located in the non-existant gcc-3.4.3-orig folder>
patching file gcc/config.gcc
can't find file to patch at input line 51
perhaps you used the wrong -p or --strip options
The text leading up to this was:
<lots of crap involving diff on two files named "atomicity.h", one being located in the non-existant gcc-3.4.3-orig folder>
I am not really from outer space.
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
That's weird. It didn't do that on my system.
Try patching it manually. Go into the gcc-3.4.3 directory, and do this:
That should do the trick, I hope. Then you need to do the same thing with the newlib patch.
Try patching it manually. Go into the gcc-3.4.3 directory, and do this:
Code: Select all
cat ../patches/gcc* > patch -p 1
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
If my computer were working (it isn't - it started crashing during boot on Sunday, and it now only works intermittently, so I'm using a laptop), I could probably just build a working, known-good toolchain, and upload that. I'm fairly sure I could make it work on pretty much every Linux distribution since RedHat 7, and I'm also fairly sure that nobody around here is using anything that old.
If anyone else wants to try that, the idea is that you compile GCC, binutils, and the KOS utilities using APBuild, which will modify the linking so the resulting binary will run on the oldest possible version of glibc (2.2, I think). Since GCC doesn't use any additional libraries, and doesn't really care too much where you install it to, the resulting binaries should run on just about anything, no matter where it's installed to.
Anyone tried getting some IDE (Anjuta, KDevelop, Eclipse, whatever) to use the DC cross compiler? Shouldn't be all that hard if you use the kos-xxx wrappers.
If anyone else wants to try that, the idea is that you compile GCC, binutils, and the KOS utilities using APBuild, which will modify the linking so the resulting binary will run on the oldest possible version of glibc (2.2, I think). Since GCC doesn't use any additional libraries, and doesn't really care too much where you install it to, the resulting binaries should run on just about anything, no matter where it's installed to.
Anyone tried getting some IDE (Anjuta, KDevelop, Eclipse, whatever) to use the DC cross compiler? Shouldn't be all that hard if you use the kos-xxx wrappers.
-
- DCEmu Ultra Poster
- Posts: 1754
- Joined: Wed Jul 17, 2002 11:25 am
- Has thanked: 0
- Been thanked: 0
WHAT? You're developing for Sony systems now?AntiPasta wrote:Yeah, trying to get something done on Saturn without using SGL/SBL made me succumb to the dark sideAlexvrb wrote:What's this, is AntiPasta going to dev for the DC now?
If you have twenty monkeys,
banging randomly on typewriters,
they will in twenty minutes produce the complete source code to World of Warcraft.
banging randomly on typewriters,
they will in twenty minutes produce the complete source code to World of Warcraft.
-
- Insane DCEmu
- Posts: 147
- Joined: Thu Dec 30, 2004 7:12 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Hi. i tried to build my enviroment, but i got in panic!!!.
When i was in "make build-sh4" it didn't work. Ye, it was scary.
This is the log: In the console this appears:
make: *** [build-sh4-binutils] Error 2
And in the log file:
.
.
make[4]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas/doc'
Making all in po
make[4]: Entering directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas/po'
make[4]: No se hace nada para `all'.
make[4]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas/po'
make[4]: Entering directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.15/gas -I. -D_GNU_SOURCE -I. -I../../binutils-2.15/gas -I../bfd -I../../binutils-2.15/gas/config -I../../binutils-2.15/gas/../include -I../../binutils-2.15/gas/.. -I../../binutils-2.15/gas/../bfd -I../../binutils-2.15/gas/../intl -I../intl -DLOCALEDIR="\"/usr/local/dc/sh-elf/share/locale\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -c ../../binutils-2.15/gas/app.c
In file included from ./targ-cpu.h:1,
from ../../binutils-2.15/gas/config/obj-elf.h:42,
from ./obj-format.h:1,
from ../../binutils-2.15/gas/config/te-generic.h:19,
from ./targ-env.h:1,
from ../../binutils-2.15/gas/as.h:626,
from ../../binutils-2.15/gas/app.c:30:
../../binutils-2.15/gas/config/tc-sh.h:106: error: el tipo matriz tiene tipo de elemento incompleto
make[4]: *** [app.o] Error 1
make[4]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
make[1]: *** [all-gas] Error 2
make[1]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15'
What can i do to fix this?
When i was in "make build-sh4" it didn't work. Ye, it was scary.
This is the log: In the console this appears:
make: *** [build-sh4-binutils] Error 2
And in the log file:
.
.
make[4]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas/doc'
Making all in po
make[4]: Entering directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas/po'
make[4]: No se hace nada para `all'.
make[4]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas/po'
make[4]: Entering directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.15/gas -I. -D_GNU_SOURCE -I. -I../../binutils-2.15/gas -I../bfd -I../../binutils-2.15/gas/config -I../../binutils-2.15/gas/../include -I../../binutils-2.15/gas/.. -I../../binutils-2.15/gas/../bfd -I../../binutils-2.15/gas/../intl -I../intl -DLOCALEDIR="\"/usr/local/dc/sh-elf/share/locale\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -c ../../binutils-2.15/gas/app.c
In file included from ./targ-cpu.h:1,
from ../../binutils-2.15/gas/config/obj-elf.h:42,
from ./obj-format.h:1,
from ../../binutils-2.15/gas/config/te-generic.h:19,
from ./targ-env.h:1,
from ../../binutils-2.15/gas/as.h:626,
from ../../binutils-2.15/gas/app.c:30:
../../binutils-2.15/gas/config/tc-sh.h:106: error: el tipo matriz tiene tipo de elemento incompleto
make[4]: *** [app.o] Error 1
make[4]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15/gas'
make[1]: *** [all-gas] Error 2
make[1]: Leaving directory `/home/daniel/Daniel/DC/build-binutils-sh-elf-2.15'
What can i do to fix this?
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
http://www.geocities.com/instructivus
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
I don't know - I can't read the error messages.
What system are you running, and what version of GCC / binutils do you have:
What system are you running, and what version of GCC / binutils do you have:
Code: Select all
gcc --version
as --version
-
- Insane DCEmu
- Posts: 147
- Joined: Thu Dec 30, 2004 7:12 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Thee once used in this threat. gcc is 3.4.3 and binutils is 2.15
I followed all the steps in the guide but i got this errors.
I followed all the steps in the guide but i got this errors.
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
http://www.geocities.com/instructivus
-
- Insane DCEmu
- Posts: 147
- Joined: Thu Dec 30, 2004 7:12 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
The lsat ones. 4.xxx. But i alse have gcc-3.4 as my compiler. but the dafualt one(the one you launch when writing gcc is 4)
I yhink i may try with the 3.4 but haw can i make my default compiler gcc-3.4?
I yhink i may try with the 3.4 but haw can i make my default compiler gcc-3.4?
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
http://www.geocities.com/instructivus
-
- Damn Dirty Ape
- Posts: 5031
- Joined: Thu Nov 07, 2002 11:11 pm
- Location: Saugerties, NY
- Has thanked: 0
- Been thanked: 0