PDA

View Full Version : DC Dev R4 Dev-C++ Guide



Elven6
March 13th, 2008, 19:57
Heres a guide to get Dev-C++ to do things that would make it compatible with the Dreamcast file type. Im working from the old R2 guide, but im just making adjustments to bring it up to date.

This is my first guide, so please be easy on it, unlike whats happened to the other guides, I will do my best to keep things updated and answer and questions you may have.

Pre-Req:
Dev C++ (http://www.bloodshed.net/index.html)
DC Dev R4 (http://www.dcemu.co.uk/vbulletin/showthread.php?p=2148033051#post2148033051)
A Dreamcast (Duh!)

Some minor knowledge in Computer Science will help ALOT.

Note: This guide assumes the directory that Cygwin is installed in is c:\cygwin, for the sake of simplicity please install it in the default directory.

1) Setting up the compiler
a) Go to Tools Menu -> Compiler options
b) Create a new compiler, name it Dreamcast
c) Add this to the compiler commands : -O2 -DFRAME_POINTERS -ml -m4-single-only -fno-optimize-sibling-calls -D_arch_dreamcast -D_arch_sub_pristine -Wall-g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000-nostartfiles -nostdlib
d) Add this to the linker commands : -g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000 -nostartfiles -nostdlib -Wall-g C:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\kernel\startup.o -lstdc++ -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group

Note: Notice the -Wall-g command in both of the commands above, depending on the program you are using, it may require a space ex: -Wall -g, the hello world program show below will not, however other programs probably will, so be on the look out for it.

2) Setting up the directories
a) Directories Tab
b) Binaries Sub-Tab
c) Add the following:
c:\cygwin\bin
c:\cygwin\usr\local\dc\sh-elf\bin
d) Libraries Sub-Tab
e) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\lib\dreamcast
c:\cygwin\usr\local\dc\kos\kos\addons\lib\dreamcas t
c:\cygwin\usr\local\dc\sh-elf
f) C Includes Sub-Tab
g) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\include
c:\cygwin\usr\local\dc\kos\kos-ports\include
c:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\include
c:\cygwin\usr\local\dc\kos\kos\addons\include
c:\cygwin\usr\local\dc\sh-elf\sh-elf\include
h) C++ Includes Sub-Tab
i) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\include
c:\cygwin\usr\local\dc\kos\kos-ports\include
c:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\include
c:\cygwin\usr\local\dc\kos\kos\addons\include
c:\cygwin\usr\local\dc\sh-elf\sh-elf\include
c:\cygwin\usr\local\dc\sh-elf\include\c++\3.4.6

3) Linking programs
a) Go To The Programs Tab
b) Set the following programs to these:
gcc -> sh-elf-gcc.exe
g++ -> sh-elf-g++.exe
gprof -> sh-elf-gprof.exe

4) The Hello World Test
a) File -> New -> Project
b) Empty Project
c) Project -> Project Options
d) Compiler Tab
e) Select the Dreamcast compiler, then go to build options, at the bottom check the override box and change the extension to .elf ex: project1.exe -> project1.elf
f) Click OK
g) Project -> New File
h) Type the following:

#include <kos.h>
KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
int main(int argc, char **argv) {
printf("\nhello world\n\n");
return 1;
}
i) File -> Save
j) Save as main.c
k) Execute -> Compile

You should know have a .elf file in the folder you saved your project too. You can upload it to your Dreamcast via Dctool OR convert the file and run it in a emulator OR using Bootdreams to burn it to a disc. (Don't ask me how to convert because I don't know how either)

So what do you think? If you liked it then please visit my blog (link is in my signature), if you have any questions please leave them below.

Elven6
March 13th, 2008, 22:02
I was hoping this could be moved to the guide section aswell, since I don't have access to post their.

Bear_XI
March 16th, 2008, 00:19
Thanks for the Guide Elven6.Its a lot easier to compile now.

Elven6
March 16th, 2008, 00:24
Thanks, the fricken thing is giving me trouble compiling me code now! Even if the code is a Dreamcast port source!!!

Wow thats weird, in the original post's source file, their are no spaces in Dreamcast, but in the submitted post it says Dreamcas t!

Bear_XI
March 16th, 2008, 00:50
When I copied the compiler commands it automatically made a space between "S" and "T".But now it works for me.
There is space to fix: (SPOILER)

1) Setting up the compiler
a) Go to Tools Menu -> Compiler options
b) Create a new compiler, name it Dreamcast
c) Add this to the compiler commands : -O2 -DFRAME_POINTERS -ml -m4-single-only -fno-optimize-sibling-calls -D_arch_dreamcast<--HERE
-D_arch_sub_pristine -Wall-g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000-nostartfiles -nostdlib
d) Add this to the linker commands : -g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000 -nostartfiles -nostdlib -Wall-g C:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\kernel\startup.o -lstdc++ -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
2) Setting up the directories
a) Directories Tab
b) Binaries Sub-Tab
c) Add the following:
c:\cygwin\bin
c:\cygwin\usr\local\dc\sh-elf\bin
d) Libraries Sub-Tab
e) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\lib\dreamcast<--HERE
c:\cygwin\usr\local\dc\kos\kos\addons\lib\dreamcas t<--HERE
c:\cygwin\usr\local\dc\sh-elf
f) C Includes Sub-Tab
g) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\include
c:\cygwin\usr\local\dc\kos\kos-ports\include
c:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\include<--HERE
c:\cygwin\usr\local\dc\kos\kos\addons\include
c:\cygwin\usr\local\dc\sh-elf\sh-elf\include
h) C++ Includes Sub-Tab
i) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\include
c:\cygwin\usr\local\dc\kos\kos-ports\include
c:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\include<--HERE
c:\cygwin\usr\local\dc\kos\kos\addons\include
c:\cygwin\usr\local\dc\sh-elf\sh-elf\include
c:\cygwin\usr\local\dc\sh-elf\include\c++\3.4.6

fackue
March 16th, 2008, 02:06
I wrote a program a long time ago that adds all this info to Dev-C++'s settings file but I didn't release it because I didn't know of a way to add the startup.o object linked in without needed it in your project's directory.

I'll take a look at your tutorial and release it if it works like I'd like. I also have a Dreamcast project file I made that works with Dev-C++ also.

Elven6
March 16th, 2008, 16:31
When I copied the compiler commands it automatically made a space between "S" and "T".But now it works for me.
There is space to fix: (SPOILER)

1) Setting up the compiler
a) Go to Tools Menu -> Compiler options
b) Create a new compiler, name it Dreamcast
c) Add this to the compiler commands : -O2 -DFRAME_POINTERS -ml -m4-single-only -fno-optimize-sibling-calls -D_arch_dreamcast<--HERE
-D_arch_sub_pristine -Wall-g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000-nostartfiles -nostdlib
d) Add this to the linker commands : -g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000 -nostartfiles -nostdlib -Wall-g C:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\kernel\startup.o -lstdc++ -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
2) Setting up the directories
a) Directories Tab
b) Binaries Sub-Tab
c) Add the following:
c:\cygwin\bin
c:\cygwin\usr\local\dc\sh-elf\bin
d) Libraries Sub-Tab
e) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\lib\dreamcast<--HERE
c:\cygwin\usr\local\dc\kos\kos\addons\lib\dreamcas t<--HERE
c:\cygwin\usr\local\dc\sh-elf
f) C Includes Sub-Tab
g) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\include
c:\cygwin\usr\local\dc\kos\kos-ports\include
c:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\include<--HERE
c:\cygwin\usr\local\dc\kos\kos\addons\include
c:\cygwin\usr\local\dc\sh-elf\sh-elf\include
h) C++ Includes Sub-Tab
i) Add the following directories:
c:\cygwin\usr\local\dc\kos\kos\include
c:\cygwin\usr\local\dc\kos\kos-ports\include
c:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\include<--HERE
c:\cygwin\usr\local\dc\kos\kos\addons\include
c:\cygwin\usr\local\dc\sh-elf\sh-elf\include
c:\cygwin\usr\local\dc\sh-elf\include\c++\3.4.6


Yea theirs a glitch in the forum thingy, in the original source that I was writing in the forum their was no space, but when ever I posted it it would show a space.

аlex
March 21st, 2008, 17:12
I have translated this guide into Russian
http://www.dcfan.net.ru/forum/showthread.php?t=1119

Maturion
March 21st, 2008, 17:56
Awesome! Also a nice translation. ;)

Elven6
April 1st, 2008, 22:05
Thanks for the translation alex, lets hope this gets more people into Dreamcast homebrew development!

Guaripolo
April 1st, 2008, 22:31
I have translated this guide into Russian
http://www.dcfan.net.ru/forum/showthread.php?t=1119

thanks! tovarich!