Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
214 user(s) are online (196 user(s) are browsing Forums)

Members: 1
Guests: 213

NinjaCyborg, more...

Support us!

Headlines

 
  Register To Post  

Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
Since I already started working on an updated RTTR (Settlers 2.5) port for MOS, it made sense to make it my first OS4 port. The game is built like this: main executable, video plugin, audio plugin. The two plugins use SDL to handle the sound, input, GL context creation, etc. The problem is when I try to open them with dlopen() they crash. Here's stacktrace:
Quote:

_INIT_CreateInput()+0x3c (section 10 @ 0x50B0)
_INIT_CreateInput()+0xc (section 10 @ 0x5080)
native kernel module elf.library.kmod+0x0000814c
native kernel module elf.library.kmod+0x000078fc
dlopen()+0x58 (section 1 @ 0xA49044)
_ZN13DriverWrapper14LoadDriverListENS_10DriverTypeER4listINS_10DriverItemEE()+0x54c (section 1 @ 0x1F3698)
_ZN13DriverWrapper4LoadENS_10DriverTypeERSs()+0x200 (section 1 @ 0x1F3EE4)
_ZN18VideoDriverWrapper10LoadDriverEv()+0x120 (section 1 @ 0x9B2260)
_ZN11GameManager5StartEv()+0x144 (section 1 @ 0x35A0B0)
main()+0x418 (section 1 @ 0x699664)
native kernel module newlib.library.kmod+0x000020a4
native kernel module newlib.library.kmod+0x00002d0c
native kernel module newlib.library.kmod+0x00002ee8
_start()+0x170 (section 1 @ 0x16C)
native kernel module dos.library.kmod+0x00024f18
native kernel module kernel+0x0006acd0
native kernel module kernel+0x0006ad50

As you can see _INIT_CreateInput() crashes, which is one of the SDL constructors: http://code.google.com/p/os4sdl/sourc ... gaos4/SDL_os4wm.c?r=38#62
My question is, can I use SDL from SObjs? BTW, I'm using the static libdl.a from os4depot for convenience, so the main executable is linked statically.

This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
@BSzili
@BSzili

Quote:

can I use SDL from SObjs?


Yes.

Quote:

BTW, I'm using the static libdl.a from os4depot for convenience, so the main executable is linked statically.


You must link the entire thing dynamically to use sobjs with dlopen(). Whichever version you use.

There is also a libdl.so in SOBJS: I believe, which you can link inot you SDK:Local/newlib/lib drawer is not allready done.

You should link the main executable with

-ldl -lauto -use-dynld

You should build the plugins with -fPIC and link with

-shared.

You *must not* build the main excutable objects with -fPIC. ( A mistake I made during blender porting that wasted a lot of time!).

If the plugin depends on code in the main executabe then you'll likely need

-W,l--export-dynamic

when linking the main executable so as to make symbols (functions and data) visible to the plugins. (not sure how many -- that option takes might be -export or --export).

ADVANCED:

You can link static libraries into dynamic executables but there a lot of pit falls, particularly if any external plugins or sobj type libraries depend on their code.

libdl.a should be okay as it's unlikely that a plugin will load other plugins, and even if they do the relevant symbols are likely already included into the executable from the library.


Go to top
Re: Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
@broadblues
It looks like I got almost everything right (using -fPIC only on the plugins, etc.). I only used the static libdl.a, because for some reason with -use-dynld the executable go linked with libbz2.so.1.0 instead of libbz2.so. So thanks, I'll try libdl.so, and get back to you.

This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
Quote:

go linked with libbz2.so.1.0 instead of libbz2.so.


Make sure that this is true:

12.AmigaOS4:> list SObjs:libbz#?
Directory "SObjs:" on Thursday 21-Nov-13
libbz2.so.1.0 197339 ----rwed 28-Nov-10 14:55:44
> libbz2.so
libbz2.so 197339 ----rwed 20-Sep-09 00:06:54


Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
Quote:

go linked with libbz2.so.1.0 instead of libbz2.so.


Make sure that this is true:

12.AmigaOS4:> list SObjs:libbz#?
Directory "SObjs:" on Thursday 21-Nov-13
libbz2.so.1.0 197339 ----rwed 28-Nov-10 14:55:44
> libbz2.so
libbz2.so 197339 ----rwed 20-Sep-09 00:06:54


Go to top
Re: Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
@broadblues
It looks okay:
Quote:
libbz2.so.1.0.4 245743 ----rwed 09-szept-09 12:16:42
libbz2.so 245743 ----rwed hétfõ 03:13:22
> SYS:sobjs/libbz2.so.1.0.4


This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
Hmmm was the issue that it was linking against

libbz2.so.1.0 and so not running when lauched? Or not linking?

As you have 1.0.4 you might need an extra link.

libbz2.so.1.0 -> libbz2.so.1.0.4
libbz2.so -> libbz2.1.0.4

My shared objects appear to older than yours (likely mine are out of date) so I only have the one link.

This is the aspect of shared objects I hate!


Go to top
Re: Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
@broadblues
It links against the explicit version, and it won't run:
Quote:
0x00000001 (NEEDED) Shared library: [libbz2.so.1.0]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x00000001 (NEEDED) Shared library: [libstdc++.so]
0x00000001 (NEEDED) Shared library: [libgcc.so]
0x00000001 (NEEDED) Shared library: [libc.so]

I have libbz2.so.1.0.4 and its link libbz2.so in sobsj: and in the sdk drawer. I could make a libbz2.so.1.0 link, but then everyone else who has the newer sobj would have to do the same... that's not really good, I'd prefer to link agains libbz2.so.

This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
@BSzili

Quote:

I could make a libbz2.so.1.0 link, but then everyone else who has the newer sobj would have to do the same... that's not really good, I'd prefer to link agains libbz2.so.


I agree it's not an ideal way to work it, but it is the standard way to work it at this time. So anyone installing the newer sobj should have made those links. So you don't need to worry about the software not running due a missing link on the users machine.

[edit]
Ideally an installer script (for the sobj not the application) should make the links for the user
[/edit]



Go to top
Re: Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
@broadblues
I think ideally the program should be linked against libbz2.so. Anyways, I made a libbz2.so.1.0 softlink, the game started up, and crashes the same way it did with the static version of libdl.so

This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
Okay. I need to see bit more info then.

Could ypu post the link command lines for the main executable and the lugins.

And could you post more of the GR log, the disassembly and registers part as well as the stack trace.


Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
@BSzili

If you need to build something against a different version of an sobjs available in the OS4.1 install, simply add an sobjs/ subdir in your programs dir and add your special sobjs in there.

AmigaOS4.1 will first look and use sobjs in the programs main dir (if available) and only after that pick the ones from the system.

A great way to not clutter users SOBJS: with add-on .so's aswell

Go to top
Re: Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
@broadblues
Sure, here's a crashlog: http://pastebin.com/t1u1VhUZ

@Raziel
So far I'm only using stock sobjs, but I'll keep that in mind.

edit: In the end I went for linking the plugins to the executable, like I did with the previous version. This way the SDL constructors don't crash anymore, but unfortunately the game eats up my 512MB memory in no time... darn!


Edited by BSzili on 2013/11/22 15:44:32
This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
@BSzili

Quote:

Sure, here's a crashlog: http://pastebin.com/t1u1VhUZ



I can see from that that IExec isn't initilised and is still 0 so that the first call to AlloCSysObjectsTags causes a DSI (which if ignored would ISI)

Not sure why this would be, and why it's not using the main executables IExec, it may be that your plugin needs to intialise IExec in a higher priority constructor. But this would normally allready be done for a main executable.

Did you link your main executable against SDL ? That would call the constructors from the main program so that IExec was allready initialised by the startup code. Ofcourse that means loading the SDL sobj whether or not you need the plugin, which is counter productive.

Quote:

edit: In the end I went for linking the plugins to the executable, like I did with the previous version. This way the SDL constructors don't crash anymore, but unfortunately the game eats up my 512MB memory in no time... darn!


How big is this game? Are the plugins always required? In which static verses dynamic won't make much difference anyway.


Go to top
Re: Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
@broadblues
The the plugins are small, but main executable is pretty big, around ~100MB including the debug symbols. I can live with the statically linked plugins, I just wanted to remove my hacks to emulate the symbol query, avoid namespace clashes, etc. I didn't link the executable against SDL, because it doesn't use SDL at all. Maybe I'll try that later.

This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Just can't stay away
Just can't stay away


See User information
Does this use SDL_LoadObject at all? I don't think that's implemented in our SDL. I use shared objects on occasion, but without dlopen which I have no experience with.

Edit: Just noticed you said it doesn't need SDL. Still, it's worth mentioning that SDL_LoadObject isn't available... yet.

Go to top
Re: Using SDL from Sobjs
Quite a regular
Quite a regular


See User information
@MickJT
RTTR uses a plugin system. The main executable doesn't use SDL, only the audio/video plugins do. I tried both the stock libdl.so, and the static libdl.a to load them (dlopen()) to no avail. I fixed this by statically linking the plugins to the executable.

This is just like television, only you can see much further.
Go to top
Re: Using SDL from Sobjs
Home away from home
Home away from home


See User information
@BSzili

I think the fly in the ointment here is the way the SDL constructors assume that IExec is available and initialised.

I'm currently re-porting perl to newlib using shared objects for the perl modules (as opposed to the horrid hacks need for the old clib version). Once I've got the main perl distribution stabilised, I'll revisit perl_SDL and see if I get the same type of issues, if I do then SDL may require fixing.


Go to top
Re: Using SDL from Sobjs
Just can't stay away
Just can't stay away


See User information
@broadblues

Couldn't -lauto be used as a workaround in that case?

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 2 ( 0 members and 2 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project