www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - how is std.loader supposed to work on linux?

reply clayasaurus <clayasaurus gmail.com> writes:
ok, so i've changed version(Linux) to version(linux),
compiled std.loader into phobos (for some reason std.loader is not 
compiled in linux as it is windows).

Then I add version=TestMain to loader.d, and compile like so...

dmd loader.d
gcc loader.o -o loader -lphobos -lpthread -lm
loader.o(.gnu.linkonce.t_D3std6loader13record_error_FZv+0x6): In 
function `_D3std6loader13record_error_FZv':
: undefined reference to `dlerror'
loader.o(.gnu.linkonce.t_D3std6loader15ExeModule_Load_FAaZT3std6lo
der8HXModule+0x58): 
In function `_D3std6loader15ExeModule_Load_FAaZT3std6loader8HXModule':
: undefined reference to `dlopen'
loader.o(.gnu.linkonce.t_D3std6loader18ExeModule_Release_FKT3std6load
r8HXModuleZv+0xcd): 
In function `_D3std6loader18ExeModule_Release_FKT3std6loader8HXModuleZv':
: undefined reference to `dlclose'
loader.o(.gnu.linkonce.t_D3std6loader20ExeModule_GetSymbol_FKT3std6loader8
XModuleAaZPv+0xc2): 
In function 
`_D3std6loader20ExeModule_GetSymbol_FKT3std6loader8HXModuleAaZPv':
: undefined reference to `dlsym'
collect2: ld returned 1 exit status
--- errorlevel 1

So my question is, how am I suppose to get std.loader to work on linux?

What I am trying to accomplish is the conversion of the currently 
windows only project derelict (dsource.org) to linux as well.

Is std.loader on linux not done yet, or has it just been overlooked?

Also, is std.loader designed so the only thing I have to change is 
SDL.dll to libSDL.so, or do I have to use different function calls?

What can I do to get std.loader working on linux? Any suggestions would 
be welcome :)

Thanks alot.
byebye
Aug 18 2004
parent reply "Matthew" <admin.hat stlsoft.dot.org> writes:
"clayasaurus" <clayasaurus gmail.com> wrote in message
news:cg19j0$2tsh$1 digitaldaemon.com...
 ok, so i've changed version(Linux) to version(linux),
 compiled std.loader into phobos (for some reason std.loader is not
 compiled in linux as it is windows).

 Then I add version=TestMain to loader.d, and compile like so...

 dmd loader.d
 gcc loader.o -o loader -lphobos -lpthread -lm
 loader.o(.gnu.linkonce.t_D3std6loader13record_error_FZv+0x6): In
 function `_D3std6loader13record_error_FZv':
 : undefined reference to `dlerror'
 loader.o(.gnu.linkonce.t_D3std6loader15ExeModule_Load_FAaZT3std6loader8HXModule+0x58):
 In function `_D3std6loader15ExeModule_Load_FAaZT3std6loader8HXModule':
 : undefined reference to `dlopen'
 loader.o(.gnu.linkonce.t_D3std6loader18ExeModule_Release_FKT3std6loader8HXModuleZv+0xcd):
 In function `_D3std6loader18ExeModule_Release_FKT3std6loader8HXModuleZv':
 : undefined reference to `dlclose'
 loader.o(.gnu.linkonce.t_D3std6loader20ExeModule_GetSymbol_FKT3std6loader8HXModuleAaZPv+0xc2):
 In function
 `_D3std6loader20ExeModule_GetSymbol_FKT3std6loader8HXModuleAaZPv':
 : undefined reference to `dlsym'
 collect2: ld returned 1 exit status
 --- errorlevel 1

 So my question is, how am I suppose to get std.loader to work on linux?
Unfortunately, std.loader suffered a schism due to Walter and I having seriously divergent viewpoints on how to implement such a library. I think that's led to us not being terribly interested in it and/or assuming the other person would handle such issues. (Hmm, maybe I shouldn't attribute any such sentiments to big-W. But that's the way I see it, anyway.) Nonetheless, that attitude sucks badly, so I'll do my best. It seems that your problem on Linux is that you should also link libdl.a, i.e specify "-ldl" in your command.
 What I am trying to accomplish is the conversion of the currently
 windows only project derelict (dsource.org) to linux as well.

 Is std.loader on linux not done yet, or has it just been overlooked?
It is supposed to be done. But, as I said, the whole lib's been kind of left to die. I am not a little ashamed of this, particularly since it's bearing my name, so want to address it again.
 Also, is std.loader designed so the only thing I have to change is
 SDL.dll to libSDL.so, or do I have to use different function calls?
I don't know what SDL is, I'm afraid.
 What can I do to get std.loader working on linux? Any suggestions would
 be welcome :)
"-dl" would be my first, best (and only) guess. Hope that helps Matthew
Aug 18 2004
next sibling parent John Reimer <brk_6502 NOSP_AM.yahoo.com> writes:
 
What can I do to get std.loader working on linux? Any suggestions would
be welcome :)
"-dl" would be my first, best (and only) guess. Hope that helps Matthew
As Matthew suggested, -ldl should fix the problem. I was looking for a similar answer on this group a month or so ago. The linker just needs to see the dynamic linking library libdl.so. Since the linux build file doesn't include the loader.d in the phobos make process, neither does it worry about adding the -ldl option. So if you've rebuilt phobos manually, you've got to remember to add the extra link option yourself.
Aug 19 2004
prev sibling parent clayasaurus <clayasaurus gmail.com> writes:
 It seems that your problem on Linux is that you should also link libdl.a, i.e
specify "-ldl" in your command.
 
 
oops. that was it. thanks, seems to work now.
 I don't know what SDL is, I'm afraid.
a shared library that allows me to access the screen, input, sound, etc. on both windows and linux
 
 "-dl" would be my first, best (and only) guess.
 
yup. that works thanks.
Aug 19 2004