PDA

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



SweetnTasty
December 29th, 2005, 23:36
Hi all, just thought I'd let you know how you can easily set up Dev-C++ with the KOS/GCC environment that comes with DC Dev R2 ( or any other "normal" KOS/GCC setup for that matter )

Remember to replace "D:\DC_DEV\" with your cygwin base dir (eg. c:\cygwin\ for most of you)

Oh and err.. I suck at writing guides, so stick with it

1) Setting up the compiler
a) Tools Menu -> Compiler options
b) Create a new compiler if you wish ( I only use Dev-C++ for DC devving, so i use the default )
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 D:\DC_DEV\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 directories:
D:\DC_DEV\bin
D:\DC_DEV\usr\local\dc\sh-elf\bin
d) Libraries Sub-Tab
e) Add the following directories:
d:\dc_dev\usr\local\dc\kos\kos\lib\dreamcast
d:\dc_dev\usr\local\dc\kos\kos\addons\lib\dreamcas t
D:\DC_DEV\usr\local\dc\sh-elf
f) C-Includes Sub-Tab
g) Add the following directories:
d:\dc_dev\usr\local\dc\kos\kos\include
d:\dc_dev\usr\local\dc\kos\kos-ports\include
d:\dc_dev\usr\local\dc\kos\kos\kernel\arch\dreamca st\include
d:\dc_dev\usr\local\dc\kos\kos\addons\include
D:\DC_DEV\usr\local\dc\sh-elf\sh-elf\include
h) C-Includes Sub-Tab
i) Add the following directories:
d:\dc_dev\usr\local\dc\kos\kos\include
d:\dc_dev\usr\local\dc\kos\kos-ports\include
d:\dc_dev\usr\local\dc\kos\kos\kernel\arch\dreamca st\include
d:\dc_dev\usr\local\dc\kos\kos\addons\include
D:\DC_DEV\usr\local\dc\sh-elf\sh-elf\include
D:\DC_DEV\usr\local\dc\sh-elf\include\c++\3.4.2

3) Setting up programs
a) 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) Testing
a) File -> New -> Project
b) Empty Project
c) Project -> Project Options
d) Compiler Tab
e) Select the compiler you set up
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
l) Now just upload it to your DC as you normally would ( eg. dctool -b 115200 -x test.elf )

Hope this helps someone :)

EDIT: Jumped the gun a bit, for some reason gpp didnt like asm code if a certain gcc switch wasnt set..

showka
February 15th, 2006, 08:28
Hey, great guide! I was able to set the thing up in a little over thirty minutes, and I've never done this kind of stuff before. I had no idea Dev-Cpp was so flexible.

So far it seems to work fine on the example, although it may be trouble to get the paths working for some of the more complex examples included in the Dev Iso. I'm sure I can get it working though. :)

_lo_
February 16th, 2006, 09:22
Hi,
I just set up the DC dev Iso R2.
This guide is really great, thx:)

The hello world example is working fine,
but I have problems with this:
---------------------------------
#include <kos.h>


int main(int argc, char **argv) {
int x, y;

/* Bother us with output only if something died */
dbglog_set_level(DBG_DEAD);

/* Set the video mode */
vid_set_mode(DM_640x480, PM_RGB565);

for (y=0; y<480; y++)
for (x=0; x<640; x++) {
int c = (x ^ y) & 255;
vram_s[y*640+x] = ((c >> 3) << 12)
| ((c >> 2) << 5)
| ((c >> 3) << 0);
}

/* Pause to see the results */
usleep(5*1000*1000);

return 0;
}

------------------------------------------

An error is shown:
28 F:\Dev-Cpp\Examples\DreamCast\main.c `usleep' undeclared (first use this function)

My added linker commands:

-g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000 -g -fno-builtin -fno-strict-aliasing -ml -m4-single-only -Wl,-Ttext=0x8c010000 -nostartfiles -nostdlib -Wall-g F:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\kernel\startup.o -lstdc++ -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group

I checked the libs and the c-inculdes.
The usleep is in the libcallisti and should be found...or am I wrong??

Any help would be great, if you need further information I'll give them to you.

Thanks in advance.

fackue
May 13th, 2007, 06:46
I've been playing around lately and found out that the reason why you got that error _lo_ is because there is no space inbetween -Wall-g. If you change it to -Wall -g it works.

_lo_
August 28th, 2007, 23:24
Thx I will try :)

fackue
August 29th, 2007, 01:52
I thought I posted a link with my Code::Blocks setup. At any rate I recommend using Code::Blocks rather than Dev-C++ because it doesn't let the order of linker objects changed. Basically, the ELF would not work in binary form (startup.o isn't the first linked object).

http://dcemulation.com/phpBB/viewtopic.php?p=960505#p960505

Elven6
March 13th, 2008, 22:43
http://www.dcemu.co.uk/vbulletin/showthread.php?goto=newpost&t=97142 heres an updated version for R4.