Getting started with programming again/

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Chilly Willy
DC Developer
DC Developer
Posts: 414
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy »

Oh, if I remember correctly, I also made a few changes to the makefile. Here's arcs of the toolchain (just under 60MB) and the cadcdev directory (just under 10MB). You can look at the makefile in cadcdev/kos/utils/dc-chain if you're interested.

Obviously you'll need to change the environ.sh script in cadcdev/kos... it currently points to where I put the stuff. You just change it to wherever you put it.

dc-dev-20100819.7z
cadcdev-20100819.7z
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Getting started with programming again/

Post by emptythought »

@ChillyWilly: Your toolchain compiled KOS r676 without a problem but it appears we have to use your enviroment path(s) which I just don't want to do, I'll have to build it myself :). However the latter log has undefined references to _fini and _init but KallistiOS has them defined in a compile time condition (GCC >= 4) :|.

Code: Select all

-------------- Build: default in Wolf4SDL\DC ---------------

[i]...[/i]

Linking console executable: Wolf4SDL.elf
/usr/local/dc/sh-elf/bin/../lib/gcc/sh-elf/4.4.4/../../../../sh-elf/lib/libc.a(lib_a-assert.o): In function `__assert':
/home/jlfenton/Projects/Dreamcast/cadcdev/kos/utils/dc-chain/build-newlib-sh-elf-1.18.0/sh-elf/newlib/libc/stdlib/../../../../../newlib-1.18.0/newlib/libc/stdlib/assert.c:73: multiple definition of `___assert'
/usr/local/dc/kos/kos/lib/dreamcast/libkallisti.a(assert.o):/usr/local/dc/kos/kos/kernel/libc/koslib/assert.c:48: first defined here
/usr/local/dc/sh-elf/bin/../lib/gcc/sh-elf/4.4.4/../../../../sh-elf/lib/libstdc++.a(eh_globals.o): In function `__static_initialization_and_destruction_0':
/home/jlfenton/Projects/Dreamcast/cadcdev/kos/utils/dc-chain/build-gcc-sh-elf-4.4.4/sh-elf/libstdc++-v3/libsupc++/../../../../gcc-4.4.4/libstdc++-v3/libsupc++/eh_globals.cc:110: undefined reference to `___dso_handle'
/usr/local/dc/kos/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_shutdown':
/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:256: undefined reference to `_fini'
/usr/local/dc/kos/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_main':
/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:208: undefined reference to `_init'
collect2: ld returned 1 exit status
Process terminated with status 1 (1 minutes, 24 seconds)
5 errors, 350 warnings
I didn't initially use your KOS archive since I had the current revision and DC Dev Environment R4's kosports-extras.7z archive merged but your KOS archive gives the same log output.

Oh, and incase anyone uses kosports-extras.7z from DDEr4 you'll need to compile the libraries since the pre-compiled libraries were compiled on Windows... wrong object format I believe. I had to fix KGLX by removing the old CVS IDs and changing all instances of

Code: Select all

(uint32)vert^=32;
to

Code: Select all

vert=((volatile pvr_vertex_t *)( ((uint32)vert)^32 ));
in gl_draw.c. If anyone needs KGLX you can download the updated source for ChillyWilly's toolchain.
Last edited by emptythought on Fri Oct 04, 2013 5:25 pm, edited 1 time in total.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy »

Not sure how to deal with C++ issues... haven't tried doing any C++ yet. :?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab »

There's an updated patch for Newlib 1.18.0 that fixes the multiple definition of ___assert problem that I threw together a little bit back that you can get here. I don't remember ever seeing the other issues, so I really can't comment on them, but I do know that I can compile C++ programs with my current toolchain after building newlib with that patch (granted, I think I've only tried some of the KOS examples).

I'll try to remember to check in the updated Newlib patch to KOS sometime soon... I've been meaning to do it, but just kept forgetting to do so.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy »

Thanks! That would have been a pain when I got around to doing something that needs C++. :grin:
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Getting started with programming again/

Post by emptythought »

Chilly Willy wrote:I got those at some point as well - it means you're missing a dependency for compiling the toolchain. I googled for the error message - saw what libs/packages/whatever had to be installed, then recompiled, then repeated until it finally went through.
Do you remember what package was required for you to download when you compiled your toolchain? Here's the error I keep getting even after installing binutils-dev from Ubuntu's package manager:
make[4]: Nothing to be done for `info-am'.
make[4]: Leaving directory `/usr/local/dc/kos/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd'
make[3]: *** [info-recursive] Error 1
make[3]: Leaving directory `/usr/local/dc/kos/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd'
make[2]: *** [all-bfd] Error 2
make[2]: Leaving directory `/usr/local/dc/kos/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/dc/kos/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1'
Does anyone know what the reverse (-R) option is that patch\diff prompts you about when patches have already bee applied? I hate deleting the source then unpacking them over, and over.

Oh, and I commited BlueCrab's patch to KallistiOS r677.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy »

You need to post more of the output. That last little bit doesn't help.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab »

emptythought wrote:Oh, and I commited BlueCrab's patch to KallistiOS r677.
I can handle committing my own patches, ya know. :wink:

Once I'm reminded to do so anyway. :lol:
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Getting started with programming again/

Post by emptythought »

@BlueCrab: Well, that patch doesn't really do much for dc-chain -- ChillyWilly's Makefile and the scripts need to be committed and updated respectively, too.

Code: Select all

WARNING: `makeinfo' is missing on your system.  You should only need it if
         you modified a `.texi' or `.texinfo' file, or any other file
         indirectly affecting the aspect of the manual.  The spurious
         call might also be the consequence of using a buggy `make' (AIX,
         DU, IRIX).  You might want to install the `Texinfo' package or
         the `GNU make' package.  Grab either from any GNU archive site.
make[4]: *** [bfd.info] Error 1
make[4]: Leaving directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd/doc'
Making info in po
make[4]: Entering directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd/po'
make[4]: Nothing to be done for `info'.
make[4]: Leaving directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd/po'
make[4]: Entering directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd'
make[4]: Nothing to be done for `info-am'.
make[4]: Leaving directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd'
make[3]: *** [info-recursive] Error 1
make[3]: Leaving directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1/bfd'
make[2]: *** [all-bfd] Error 2
make[2]: Leaving directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/dc/kos_677/kos/utils/dc-chain/build-binutils-sh-elf-2.20.1'
Suppose I need makeinfo... /me is off to find the package.

EDIT: On Ubuntu sudo apt-get install texinfo should install it, or search for texinfo in Synaptic and install it. It compiles past binutils fine here and onto pass 1 of the SH-4 compiler.
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Getting started with programming again/

Post by emptythought »

I have the toolchain compiling but the compiler still gives me fini, init and a new error:

Code: Select all

Linking console executable: Wolf4SDL.elf
/usr/local/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/lib/libstdc++.a(eh_globals.o): In function `__static_initialization_and_destruction_0':
/usr/local/dc/kos_677/kos/utils/dc-chain/build-gcc-sh-elf-4.4.4/sh-elf/libstdc++-v3/libsupc++/../../../../gcc-4.4.4/libstdc++-v3/libsupc++/eh_globals.cc:110: undefined reference to `___dso_handle'
/usr/local/dc/kos_677/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_shutdown':
/usr/local/dc/kos_677/kos/kernel/arch/dreamcast/kernel/init.c:256: undefined reference to `_fini'
/usr/local/dc/kos_677/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_main':
/usr/local/dc/kos_677/kos/kernel/arch/dreamcast/kernel/init.c:208: undefined reference to `_init'
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab »

emptythought wrote:I have the toolchain compiling but the compiler still gives me fini, init and a new error:

Code: Select all

Linking console executable: Wolf4SDL.elf
/usr/local/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/lib/libstdc++.a(eh_globals.o): In function `__static_initialization_and_destruction_0':
/usr/local/dc/kos_677/kos/utils/dc-chain/build-gcc-sh-elf-4.4.4/sh-elf/libstdc++-v3/libsupc++/../../../../gcc-4.4.4/libstdc++-v3/libsupc++/eh_globals.cc:110: undefined reference to `___dso_handle'
/usr/local/dc/kos_677/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_shutdown':
/usr/local/dc/kos_677/kos/kernel/arch/dreamcast/kernel/init.c:256: undefined reference to `_fini'
/usr/local/dc/kos_677/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_main':
/usr/local/dc/kos_677/kos/kernel/arch/dreamcast/kernel/init.c:208: undefined reference to `_init'
Well, the only thing the patch said that it did was get rid of the ___assert issue. As I said, I've never seen the _init and _fini issue, but it looks to me like something isn't getting linked that should in your Makefile. The _init and _fini symbols are both defined in GCC's crti.asm, which should be linked in by default if you're not doing anything too loopy in your Makefile. Also, the __dso_handle thing should be a part of the normal linking process, if I'm not mistaken.

I'm guessing this is some kind of Makefile issue, or an environment issue. Either you're not using the built-in stuff in the environ script, or your environment is screwed up, and this part of the environ script is ending up in the non 4.x case:

Code: Select all

GCCVER="`kos-cc -v 2>&1 | tail -1 | awk '{print $3}'`"

case $GCCVER in
  4*)
    export KOS_LDFLAGS="${KOS_LDFLAGS} -T${KOS_BASE}/utils/ldscripts/shlelf.xc -nodefaultlibs ${KOS_LIB_PATHS}" ;;
  *)
    export KOS_LDFLAGS="${KOS_LDFLAGS} -nostartfiles -nostdlib ${KOS_LIB_PATHS}" ;;
esac
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy »

Yeah, I was going to say those errors look like you are trying to link a "regular" program. Consoles never use the regular startup files. You may need to edit your makefile for Wolf3SDL to not link in the regular startup files.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab »

Chilly Willy wrote:Yeah, I was going to say those errors look like you are trying to link a "regular" program. Consoles never use the regular startup files. You may need to edit your makefile for Wolf3SDL to not link in the regular startup files.
Actually, its quite the opposite here. With my patch for GCC 4.x, you are actually using GCC's startup files (with one replaced in the patch with the equivalent file from KOS), whereas in the past you would not. Hence why in the 4.x path in that script, you don't have the -nostartfiles flag.
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 6 times

Re: Getting started with programming again/

Post by nymus »

The newlib patch allows everything to compile now but nothing runs. The program loads but doesn't execute when dcload passes control. Could just be me missing something again...
behold the mind
inspired by Dreamcast
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Getting started with programming again/

Post by emptythought »

Okay, my environment was setup for an old toolchain, it's setup for GCC 4.4.4 and KallistiOS r677 now.

My elf freezes at the licensing screen (using lxdream) giving "length or dest is null!" then shuts KOS down.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab »

nymus wrote:The newlib patch allows everything to compile now but nothing runs. The program loads but doesn't execute when dcload passes control. Could just be me missing something again...
Is this in C++ or C code? I know that I can run non-trivial C programs using GCC 4.4.4/4.5.1, but I haven't written any test programs using the STL in C++ to make sure that all works as expected.
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 6 times

Re: Getting started with programming again/

Post by nymus »

All the kos examples i've tried fail; both c and c++. I don't think i changed anything after i got it working but i'll do a step-by-step to look for the problem. It's most likely somethinng in my environ files if it's working for others.
behold the mind
inspired by Dreamcast
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 6 times

Re: Getting started with programming again/

Post by nymus »

A combination of the following changes to the environment got it working

- changed the path in the ldscript to my set-up (not sure if it helped)
- set -tText as cflag (didn't get it working but allowed me to)
- delete global ldflag export and subsequent reference (i.e. kos_ldflag = kos_ldflag )

I believe the ldflag duplication was the culprit. It seemed to persist across KDE konsole sessions too.

Thanks for the great work.
behold the mind
inspired by Dreamcast
Post Reply