PDA

View Full Version : SDL driver 1.29 strange error



Azuki
January 14th, 2006, 01:38
Hi everybody,

I use :

Dev C++ : FreeDev pack
sh_gcc : 3.4.2
gcc : 3.4.2
kos : 1.2.0


1 )i have downloaded the precompiled librairies, in my IDE directory i have placed
the content of lib/dreamcast (*.a files) in my lib directory (dclib).

2) i copy the "freetype directory" in my include directory (there was none before)

3) i copy the content of "SDL include directory" in my previous "SDL include directory"

4) i move "zlib.h,zconf.h,zutil.h" to the "zlib include directory" in my IDE

5) i move "png.h pngconf.h" to the "png include directory" in my IDE

6) i do not know where to copy the last file "ft2build.h" so i keep it in the root directory of
my include files.

After doing that, i add the "-lSDL_129" prefix in the linker options

i also add in my source file the header "SDL_dreamcast.h".

Finally i try to compile my project wich compile smoothly using my old
installation (before making point 1 to 6).

At this point "big problemo" begins :


Compiler: Dreamcast
Building Makefile: "C:\Makefile.win"
Executing make...
make.exe -f "C:\Makefile.win" all
sh-elf-gcc.exe testing_sdl_chui/Test_sdl.o -o "test.elf" -L"d:/Dev-Cpp/dclib" -L"d:/Dev-Cpp/dclib"
-lSDL_129 -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 startup.o
-lkallisti -lgcc testing_sdl_chui/romdisk.o
testing_sdl_chui/Test_sdl.o(.eh_frame+0x12): In function `My_game':
testing_sdl_chui/Test_sdl.cpp:372: undefined reference to `___gxx_personality_v0'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_error.o)(.text+0x6d0): In function `SDL_SetError':
src/SDL_error.c:120: undefined reference to `__impure_ptr'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_error.o)(.text+0x6d4):
src/SDL_error.c:120: undefined reference to `_fprintf'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_error.o)(.text+0x744):
src/SDL_error.c:296: undefined reference to `__impure_ptr'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_error.o)(.text+0x748):
src/SDL_error.c:296: undefined reference to `_fprintf'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_systimer.o)(.text+0x3c):
In function `SDL_GetTicks':
src/timer/dc/SDL_systimer.c:61: undefined reference to `_timer_us_gettime64'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_sysjoystick.o)(.text+0x358): In function `SDL_SYS_JoystickUpdate':
src/joystick/dc/SDL_sysjoystick.c:219: undefined reference to `_timer_us_gettime64'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_dcvideo.o)(.text+0x598): In function `sdl_dc_blit_textured':
src/video/dc/SDL_dcvideo.c:618: undefined reference to `_pvr_dma_ready'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_dcvideo.o)(.text+0x688): In function `DC_FlipHWSurface':
src/video/dc/SDL_dcvideo.c:670: undefined reference to `_pvr_dma_ready'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_dcvideo.o)(.text+0x68c):src/video/dc/SDL_dcvideo.c:670:
undefined reference to `_pvr_dma_transfer'
d:/Dev-Cpp/dclib/libSDL_129.a(SDL_dcevents.o)(.text+0x224): In function `DC_PumpEvents':
src/video/dc/SDL_dcevents.c:104: undefined reference to `_timer_us_gettime64'
collect2: ld returned 1 exit status
Execution terminated

If i remove the "-lSDL_129" switch in my linker profile to use "-lSDL" like before my project does not compile anymore :

Building Makefile: "C:\Makefile.win"
Executing make...
make.exe -f "C:\Makefile.win" all
sh-elf-gcc.exe testing_sdl_chui/Test_sdl.o -o "test.elf" -L"d:/Dev-Cpp/dclib" -L"d:/Dev-Cpp/dclib"
-lSDL -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 startup.o
-lkallisti -lgcc testing_sdl_chui/romdisk.o testing_sdl_chui/Test_sdl.o(.eh_frame+0x12):
In function `My_game':
test_de_sdl/Test_sdl.cpp:372: undefined reference to `___gxx_personality_v0'
collect2: ld returned 1 exit status
Execution terminated

And i start cry .... just one minute the time needed to delete my include and lib directories
and to move on my backup directories.

So what is wrong ? :confused: It will nice helping me :)

ron
January 16th, 2006, 10:14
Use KOS 1.3 instead KOS 1.2.

The better thing you can do is to download SDL SOURCE for chui's page http://chui.dcemu.co.uk and compile yourself.

Change <SDL_dreamcast.h> to <SDL/SDL.h>

Test_sdl.cpp:372: undefined reference to `___gxx_personality_v0' this seems to be an error in your source, an undefined reference , check your source and begin compiling the Chui's examples in C. I just use the mode c++ when compiling becasue GCC is more efficient when compiling c++ than c.. I use 3.4.2

I hope you can solve the pbms. Take it easy, else you always have the option to download DCDEV CD, that includes a complete set to configure your cygwin environment is case of use windows. A linux environment is always better, anyway should work fine.

The Link: http://www.consolevision.com/dreamcast/dev/

And more info about: http://www.dcemulation.com/phpBB/viewtopic.php?p=808467

Good luck

Azuki
January 17th, 2006, 21:23
Hi Ron !

Well, you say that i should use kos 1.3 instead of 1.2 : it will be nice but in Devc++ packaging it seems to be hard to upgrade from the KOs 1.2.0 /sh-elf 3.0.4 release.

Some people say it's just a question of "copy/paste" assuming it needs only to replace "shelf" directory to the version you want and replace "dclib" / "dcinclude" directories
with the ones compiled by the new "shelf" upgrade.

To be clear (my english is certainly wicked) :

X:/devcpp/shelf/ (3.04.) replaced by X:/devcpp/shelf/ (3.4.2)

X:/devcpp/dcinclude/ & X:/devcpp/dclib/
(kos 1.2.0 and some libs maked by shelf 3.0.4 )

replaced by

X:/devcpp/dcinclude/ & X:/devcpp/dclib/
(kos 1.3.0 and some libs maked by shelf 3.4.2)

the answer is : "it's not working" i have tested it last night : it produce big errors over 500 ...

The undefined reference to `___gxx_personality_v0' error is coming from that test, if i use the normal shelf 3.0.4, it compile fine but always with the very old SDL lib (within the pack : bero 's beta 1 or 2).

So no way to use Devc++ with kos 1.3 and new sh-elf-gcc : sad :( .
I must leave Devc++ if i want to use kos 1.3 dans sdl 1.29 :confused: ? ok ! :D

I follow your advice and DL and install "DCDEV CD" (release 2), the install process is quite simple, i notice just two little things

1) the cygwin default install does not inclde make, i must click on the dev section to activate it

2) the /bin directory is not in the path oooppps PATH (sorry) so i must use in bash
"PATH=$PATH:/bin" command.

After that i run the cygwin.bat and enter in linux land, i must say that if i type "make" in prompt, the Kos 1.3 compilation process run smoothly : well done.


i try to compile SDL 1.29, i extract the archive in a directory i call 'SDL129" here :
/usr/local/dc/kos/kos-ports/

then in /usr/local/dc/kos/kos-ports/SDL129/ with bash i type "make -f makefile.dc" the process start and seems to be ok

I obtain in "/usr/local/dc/kos/kos/addons/lib/dreamcast/" a sld129.a file of 916 kb and a libkosutils.a file (32,1kb) ...

Then, i try to compile my test.cpp file using 2 commands in bash

normally, it look like this :

sh-elf-gcc.exe -c test_sdl/Test_sdl.cpp -o test_de_sdl/Test_sdl.o -I"INCLUDE_FOLDER" -Wall -g -ml -mbigtable -m4-single-only -O3 -nostartfiles -nodefaultlibs -nostdlib -fno-builtin -fno-strict-aliasing -fomit-frame-pointer -fno-optimize-sibling-calls -D_arch_dreamcast

and then

sh-elf-gcc.exe test_sdl/Test_sdl.o -o "test.elf" -L"LIBRARY_FOLDER" -lSDL_129 -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 startup.o -lkallisti -lgcc

But again big problemos lurking at me :

in devc++ INCLUDE_FOLDER => X:/devcpp/dcinclude
LIBRARY_FOLDER => X:/devcpp/dclib
but here where are they :eek: ?

is it "/usr/local/dc/kos/kos/include" or /usr/local/dc/kos/kos/kernel/arch/dreamcast/include"

or "/usr/local/dc/kos/kos/libc/include" or "/usr/local/dc/kos/kos/addons/include" ...

and

"/usr/local/dc/kos/kos/lib/dreamcast" or "/usr/local/dc/kos/kos/addons/lib/dreamcast" or

"/usr/local/dc/kos/kos/lib" ?

GPF
January 17th, 2006, 22:04
Compile C code with sh-elf-gcc, C++ code with sh-elf-g++.

Azuki
January 18th, 2006, 20:13
Cygwin install on F:
Kos 1.3
shelfgcc 3.4.2

Well, i use a sample code in C very simple :

#include <kos.h>

int main(int argc, char *argv[])
{
return 0;
}

difficult to make more easy :)

step one : i use those commands in bash

sh-elf-gcc.exe -c /test_de_sdl/Test_sdl.c -o /test_de_sdl/Test_sdl.o -I"F:\cygwin\usr\local\dc\kos\kos-ports\include" -I"F:\cygwin\usr\local\dc\kos\kos\include" -I"F:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamca st\include" -I"F:\cygwin\usr\local\dc\kos\kos\addons\include" -I"F:\cygwin\usr\local\dc\kos\kos-ports\SDL129\include" -Wall -g -ml -mbigtable -m4-single-only -O3 -nostartfiles -nodefaultlibs -nostdlib -fno-builtin -fno-strict-aliasing -fomit-frame-pointer -fno-optimize-sibling-calls -D_arch_dreamcast

i have figure out the include directories since my last post ...

I obtain a nice Test_sdl.o file

Step 2 : i use this

sh-elf-gcc.exe /test_de_sdl/Test_sdl.o -o "test.elf" -L"F:\cygwin\usr\local\dc\kos\kos\lib\dreamcast" -L"F:\cygwin\usr\local\dc\kos\kos\addons\lib\dreamcas t" -lSDL_129 -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 /test_de_sdl/startup.o /test_de_sdl/romdisk.o -lkallisti -lgcc

i have figure out the lib directories since my last post

i obtain errors messages :


.
.
.
.
.


F:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(pvr_prim.o)(.text+0x4c4):
In function `pvr_poly_cxt_txr':/usr/local/dc/kos/kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c:190:
undefinedreference to `_memset'

F:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(pvr_prim.o)(.text+0x5a4):
In function `pvr_sprite_cxt_txr':/usr/local/dc/kos/kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c:231:
undefined reference to `_memset'



.
.
.
.
.
.


F:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(vmu_pkg.o)(.text+0x258):
/usr/local/dc/kos/kos/kernel/arch/dreamcast/util/vmu_pkg.c:110: undefined reference to `_memset'

F:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(vmu_pkg.o)(.text+0x25c):
/usr/local/dc/kos/kos/kernel/arch/dreamcast/util/vmu_pkg.c:110:undefined reference to `_memcpy

'F:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(vmu_pkg.o)(.text+x260):
/usr/local/dc/kos/kos/kernel/arch/dreamcast/util/vmu_pkg.c:110: undefined reference to `_strcpy'

F:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(vmu_pkg.o)(.text+0x3ac):
In function `vmu_pkg_parse':/usr/local/dc/kos/kos/kernel/arch/dreamcast/util/vmu_pkg.c:157: undefined reference to `_memcpy'collect2: ld

returned 1 exit status
BASH-3.00$


any ideas ?

GPF
January 18th, 2006, 21:03
either your missing a library or the order is incorrect on the link line. sorry not sure which lib has memset, memcpy and strcpy

have you tried running the same command under cygwin, take current command from above swap the \ for a / and run and see if it complain about same errors.

sh-elf-gcc.exe /test_de_sdl/Test_sdl.o -o "test.elf" -L"F:/cygwin/usr/local/dc/kos/kos/lib/dreamcast" -L"F:/cygwin/usr/local/dc/kos/kos/addons/lib/dreamcas t" -lSDL_129 -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 /test_de_sdl/startup.o /test_de_sdl/romdisk.o -lkallisti -lgcc

looks like your getting pretty close though best of luck

quzar
January 18th, 2006, 21:31
i don't see him linking -lc anywhere, maybe that is a problem, seeing as that most of his problems are standard lib C functions?

Azuki
January 19th, 2006, 20:26
Well, i follow those interresting advice.
I copy paste the line with "/" but in cygwin it does not change anything.

I think you are all right yes GPF it's certainly a link problem and quzar
i have seen a very interresting doc for libc.a.

It's here : http://www.delorie.com/djgpp/doc/libc/

As you can seen all the undefined functions errors are listed in libc.a (especially memset and co).

The only file named libc.a in the cygwing install of DC DEV ios r2 is in :
"f:\cygwin\lib" or "f:\cygwin\usr\local\dc\sh-elf\sh-elf\lib\ml\m4-single-only".

I choose the second one and add the directory to my command line :

-L"f:\cygwin\usr\local\dc\sh-elf\sh-elf\lib\ml\m4-single-only" and -lc

I play around withe the different positions of the three main lib i have to link :

"-lkallisti"
"-lgcc"
"-lc"

After some manipulations i set this order wich produce very much less errors than my previous attempts :

-lkallisti -lgcc -lc

libc.a is the core C functions library, libgcc.a is the library needed by gcc and libkallisti.a is the os.

So it's strange but it seems that in gcc the last is the first in link order. In this example the -lc switch is considered first even if it's in the end of the command ....

After that i have examinded closely startup.s file and i found those line in the top of the file :

! KallistiOS ##version##
!
! startup.s
! (c)2000-2001 Dan Potter
!
! This file must appear FIRST in your linking order, or your program won't
! work correctly as a raw binary.

"FIRST in your linking order"
So according to my strange order rule i put the startup.o file on the end of the command

-lkallisti -lgcc -lc startup.o


To resume i use that :

sh-elf-gcc.exe /test_de_sdl/Test_sdl.o -o "test.elf" -L"F:\cygwin\usr\local\dc\sh-elf\sh-elf\lib\ml\m4-single-only" -L"F:/cygwin/usr/local/dc/kos/kos/lib/dreamcast" -L"F:/cygwin/usr/local/dc/kos/kos/addons/lib/dreamcast" -lSDL_129 -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 /test_de_sdl/romdisk.o -lkallisti -lgcc -lc /test_de_sdl/startup.o

When i start compiling i obtain only 3 errors (less again) :

/test_de_sdl/startup.o(.text+0xdc): In function `main_addr':
: undefined reference to `_arch_main'

/test_de_sdl/startup.o(.text+0xe4): In function `fpscr_addr':
: undefined reference to `___set_fpscr'

/test_de_sdl/startup.o(.text+0xe8): In function `kos_init_flags_addr':
: undefined reference to `___kos_init_flags'
collect2: ld returned 1 exit status

Well the `kos_init_flags_addr' remenber me something .... the init call !

I put a "KOS_INIT_FLAGS(INIT_DEFAULT|INIT_MALLOCSTATS);" statement in my source file after the "#include <kos.h> statement.


When compiling it notice only 2 errors (again less) :

/test_de_sdl/startup.o(.text+0xdc): In function `main_addr':
: undefined reference to `_arch_main'

/test_de_sdl/startup.o(.text+0xe4): In function `fpscr_addr':
: undefined reference to `___set_fpscr'

collect2: ld returned 1 exit status


So what i understand is that i must certainly declare some fpscr and main value in my source code. Those values will be used in startup.o in the functions `_arch_main' and `___set_fpscr' first. Then the process will continue ...


But at this point i have no idea of what it is ....

Azuki
January 21st, 2006, 23:11
In fact the correct order is

sh-elf-gcc.exe /test_de_sdl/Test_sdl.o -o "test.elf"
-L"/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only"
-L"/usr/local/dc/kos/kos/lib/dreamcast"
-L"/usr/local/dc/kos/kos/addons/lib/dreamcast"
-ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000
/test_de_sdl/romdisk.o /test_de_sdl/startup.o -lSDL_129 -lkallisti -lgcc -lc


startup.o always before -l switch and library are examinded in inverso order i's written in command line.

The /usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only directoty is where i find libc.a.

well after that errors occurs :

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(time.o)(.text+0x4c): In
function `time': ../../../../../../../newlib-1.12.0/newlib/libc/time/time.c:57:
undefined reference to `__gettimeofday_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(tzset_r.o)(.text+0x2b8)
: In function `_tzset_r':../../../../../../../newlib-1.12.0/newlib/libc/time/tzset_r.c:192:
undefined reference to `__malloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(vfprintf.o)(.text+0xd38
): In function `_vfprintf_r':../../../../../../../newlib-1.12.0/newlib/libc/stdio/vfprintf.c:748:
undefined reference to `__malloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(vfprintf.o)(.text+0x154
c):../../../../../../../newlib-1.12.0/newlib/libc/stdio/vfprintf.c:1172:
undefined reference to `___umoddi3'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(wsetup.o)(.text+0x110):
In function `__swsetup':../../../../../../../newlib-1.12.0/newlib/libc/stdio/wsetup.c:55:
undefined reference to `__free_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(fvwrite.o)(.text+0x398)
: In function `__sfvwrite':../../../../../../../newlib-1.12.0/newlib/libc/stdio/fvwrite.c:136:
undefined reference to `__realloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(mprec.o)(.text+0xa8): I
n function `_Balloc':../../../../../../../newlib-1.12.0/newlib/libc/stdlib/mprec.c:125:
undefined reference to `__calloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(vfscanf.o)(.text+0x12e4
): In function `__svfscanf_r':../../../../../../../newlib-1.12.0/newlib/libc/stdio/vfscanf.c:1125:
undefined reference to `___extendsfdf2'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(strtoll_r.o)(.text+0x28
c): In function `_strtoll_r':../../../../../../../newlib-1.12.0/newlib/libc/stdlib/strtoll_r.c:122:
undefined reference to `___umoddi3'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(strtoull_r.o)(.text+0x2
2c): In function `_strtoull_r':../../../../../../../newlib-1.12.0/newlib/libc/stdlib/strtoull_r.c:102:
undefined reference to `___umoddi3'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(ungetc.o)(.text+0xac):
In function `__submore':../../../../../../../newlib-1.12.0/newlib/libc/stdio/ungetc.c:66:
undefined reference to `__realloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(ungetc.o)(.text+0xb8):.
./../../../../../../newlib-1.12.0/newlib/libc/stdio/ungetc.c:66:
undefined reference to `__malloc_r'

Something's missing but i do not see what to link after libc to be examined by gcc first and defined those missing references or is there a problem with libc provided in DC dev iso r2 ?.


there's less errors but i am always on the road ...

Azuki
January 23rd, 2006, 22:51
It seems to be solved, i pray to have never this problem again !!! :D