Manually loading shared object

This forum is for general developer support questions.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 519
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Manually loading shared object

Post by salass00 »

capehill wrote: I'm not able to build a helloworld with clib2, I get undefined reference to GetProgramName. http://forum.hyperion-entertainment.biz ... rogramname
There's an updated build of clib2 on OS4Depot which should fix that issue:

http://os4depot.net/index.php?function= ... /clib2.lha

capehill
Posts: 24
Joined: Sun Jun 18, 2017 1:07 pm

Re: Manually loading shared object

Post by capehill »

salass00 wrote:
capehill wrote: I'm not able to build a helloworld with clib2, I get undefined reference to GetProgramName. http://forum.hyperion-entertainment.biz ... rogramname
There's an updated build of clib2 on OS4Depot which should fix that issue:

http://os4depot.net/index.php?function= ... /clib2.lha
Cheers, I totally forgot to check OS4depot! :oops:

capehill
Posts: 24
Joined: Sun Jun 18, 2017 1:07 pm

Re: Manually loading shared object

Post by capehill »

softwarefailure wrote:Since nobody has an idea what's wrong here I've now requested a clib2 static link library build of SDL2:
https://sourceforge.net/p/sdl2-amigaos4/tickets/29/

Let's hope that this materialises so that I can finally finish this plugin for OS4...
It's possible to build libSDL2.a with -mcrt=clib2, but not with -mcrt=clib2-ts (-lgcc missing).

Now creating sdl2.library was an interesting suggestion. It sounds like a lot of work though. SDL2 relies on C library functions a lot so this may be a potential issue. I assume that newlib could be used though.

A native thread implementation for SDL2 might be easier goal, assuming SDL1 version can be referenced.

What features/subsystems of SDL2 do you require for your plugin?

softwarefailure
Posts: 96
Joined: Fri Feb 14, 2014 10:29 pm

Re: Manually loading shared object

Post by softwarefailure »

What features/subsystems of SDL2 do you require for your plugin?
I don't require threads. I just require the following subsystems: SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER|SDL_INIT_AUDIO. So if you can provide a clib2 version for that it would already be sufficient. Threads aren't necessary for my plugin.

User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 591
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Manually loading shared object

Post by broadblues »

capehill wrote:
softwarefailure wrote:Since nobody has an idea what's wrong here I've now requested a clib2 static link library build of SDL2:
https://sourceforge.net/p/sdl2-amigaos4/tickets/29/

Let's hope that this materialises so that I can finally finish this plugin for OS4...
It's possible to build libSDL2.a with -mcrt=clib2, but not with -mcrt=clib2-ts (-lgcc missing).
If using a recent gcc I think you need to do this.
makelink from SDK:gcc/lib/gcc/ppc-amigaos/5.4.0/clib2-ts to SDK:gcc/lib/gcc/ppc-amigaos/5.4.0/clib2
Now creating sdl2.library was an interesting suggestion. It sounds like a lot of work though. SDL2 relies on C library functions a lot so this may be a potential issue. I assume that newlib could be used though.
It's use of clibrary function is only an issue if the API requires you to pass things like sockets and filehandles as arguments, and malloc is not used, (or at least no malloced memeory is pass the to caller to free) being gfx related I'd think this was un likelty, but you never know... If all clibrary usage is internal either clib2 or newlib can easily be used in a library.

capehill
Posts: 24
Joined: Sun Jun 18, 2017 1:07 pm

Re: Manually loading shared object

Post by capehill »

softwarefailure wrote:
What features/subsystems of SDL2 do you require for your plugin?
I don't require threads. I just require the following subsystems: SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER|SDL_INIT_AUDIO. So if you can provide a clib2 version for that it would already be sufficient. Threads aren't necessary for my plugin.
SDL audio needs threads and mutexes.

capehill
Posts: 24
Joined: Sun Jun 18, 2017 1:07 pm

Re: Manually loading shared object

Post by capehill »

After some sweating I have managed to create sdl2.library. It doesn't work of course, but crashes on pthread_key_create().

Code: Select all

(0x57C49C70) [source/linklib/lib.c:380] CURRDIR:sdl2.library:pthread_key_create()+0x24 (section 1 @ 0xB5180)
(0x57C49C80) CURRDIR:sdl2.library:SDL_SYS_GetTLSData()+0xcc (section 1 @ 0x5D330)
(0x57C49CB0) CURRDIR:sdl2.library:SDL_GetErrBuf()+0x94 (section 1 @ 0x3C0E4)
(0x57C49CD0) CURRDIR:sdl2.library:SDL_ClearError()+0x10 (section 1 @ 0x30F8)
(0x57C49CE0) CURRDIR:sdl2.library:SDL_InitSubSystem()+0x2c (section 1 @ 0x24F4)
(0x57C49CF0) a.out:main()+0x38 (section 1 @ 0x38C)
(0x57C49D00) native kernel module Kickstart/newlib.library.kmod+0x00002194
(0x57C49D60) native kernel module Kickstart/newlib.library.kmod+0x00003074
(0x57C49F10) native kernel module Kickstart/newlib.library.kmod+0x00003340
(0x57C49F40) a.out:_start()+0x174 (section 1 @ 0x170)
(0x57C49F90) native kernel module Kickstart/dos.library.kmod+0x00026728
(0x57C49FC0) native kernel module Kickstart/kernel+0x0003e9a8
(0x57C49FD0) native kernel module Kickstart/kernel+0x0003e9f0
Is it allowed to link static libraries, such as libpthread.a to a native library? Should I implement a native threading solution rather?

EDIT: I called __init_threads() now manually, and it crashed now in a different place:

Code: Select all

(0x5AE71C40) LIBS:pthreads.library:hash_table_find_specific()+0x28 (section 1 @ 0x5A50)
(0x5AE71C50) LIBS:pthreads.library:get_key()+0x18 (section 1 @ 0x2190)
(0x5AE71C70) [source/linklib/lib.c:401] CURRDIR:sdl2.library:pthread_getspecific()+0x28 (section 1 @ 0xB52B8)
(0x5AE71C80) CURRDIR:sdl2.library:SDL_SYS_GetTLSData()+0x64 (section 1 @ 0x5D2E4)
(0x5AE71CB0) CURRDIR:sdl2.library:SDL_GetErrBuf()+0x94 (section 1 @ 0x3C100)
(0x5AE71CD0) CURRDIR:sdl2.library:SDL_ClearError()+0x10 (section 1 @ 0x3114)
(0x5AE71CE0) CURRDIR:sdl2.library:SDL_InitSubSystem()+0x2c (section 1 @ 0x2510)
(0x5AE71CF0) a.out:main()+0x38 (section 1 @ 0x38C)
(0x5AE71D00) native kernel module Kickstart/newlib.library.kmod+0x00002194
(0x5AE71D60) native kernel module Kickstart/newlib.library.kmod+0x00003074
(0x5AE71F10) native kernel module Kickstart/newlib.library.kmod+0x00003340
(0x5AE71F40) a.out:_start()+0x174 (section 1 @ 0x170)
(0x5AE71F90) native kernel module Kickstart/dos.library.kmod+0x00026728
(0x5AE71FC0) native kernel module Kickstart/kernel+0x0003e9a8
(0x5AE71FD0) native kernel module Kickstart/kernel+0x0003e9f0

Post Reply