FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trouble Using D On Linux

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
diepruis



Joined: 20 Aug 2006
Posts: 6

PostPosted: Tue Aug 22, 2006 2:26 pm    Post subject: Trouble Using D On Linux Reply with quote

Hi.

I'm a bit new to to D and Derelict and I was wondering if someone could point me in the right direction.

So far, I've installed dmd, build and built Derelict. Unfortunately, I'm a tad new to Linux as well and I have now idea what to do next, here's my current attempt:

* Copied Derelict sources to Phobos dir (/usr/phobos) and flattened them out according to a guide I found somwhere so that I can just do import derelict.sdl.sdl;

* Copied the .a files generated by buildme.d to /usr/lib

* Ran ldconfig

* Added -L-ldl to dmd.conf

Here's my problem:

* ldconfig didn't seem to pick up the Derelict libraries (i.e. ldconfig -p | grep derelict returns nothing). Do I have to convert the .a files to .so files somehow?

* A simple test program won't compile, like so:

Code:

import derelict.sdl.sdl;

void main() {}


which, when compiled, gives:

Code:

dmd derelict_test.d
gcc derelict_test.o -o derelict_test -m32 -lphobos -lpthread -lm -Xlinker -ldl
derelict_test.o:(.data+0x30): undefined reference to `_ModuleInfo_8derelict3sdl3sdl'
collect2: ld returned 1 exit status
--- errorlevel 1


when adding -L-llibDerelictSDL or -L-lderelictSDL
Code:

/usr/bin/ld: cannot find -llibDerelictSDL
or
/usr/bin/ld: cannot find -lderelictSDL


or -L-lDerelictSDL
Code:

/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libDerelictSDL.a(sdl.o):(.data+0x78): undefined reference to `_ModuleInfo_8derelict4util6loader'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libDerelictSDL.a(sdl.o): In function `_D8derelict4util6loader52__...etc': DerelictSDL/derelict/sdl/sdl.d: (.gnu.linkonce.t_D8derelict4util6loader52__T6BinderTT8derelict3sdl6active17pfSDL_GetAppStateZ6Binder6opCallFAaC8derelict4util6loader9SharedLibZv+0xe):  undefined reference to `_D8derelict4util6loader16Derelict_...etc' (added some spaces to this line to make php accept it)


(I had to shorten two identifiers to make php accept it.)

Sorry for the long post, but I'm completely confused, could someone give me a helping hand? I'd really appreciate a few simple pointers on how to install Derelict correctly under Linux, as I've been unable to find any documentation on this.

Thanks in advance.
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Tue Aug 22, 2006 4:44 pm    Post subject: Reply with quote

My best guess is that your static libs are incomplete. Try putting derelict in some other place than dmd's dirs, then recompile it. IIRC, Build skips subdirectories of dmd, so your libs don't actually contain too much Wink

You could also try another approach: http://dmedia.dprogramming.com/
Back to top
View user's profile Send private message MSN Messenger
diepruis



Joined: 20 Aug 2006
Posts: 6

PostPosted: Wed Aug 23, 2006 2:03 am    Post subject: Reply with quote

Quote:

My best guess is that your static libs are incomplete. Try putting derelict in some other place than dmd's dirs, then recompile it. IIRC, Build skips subdirectories of dmd, so your libs don't actually contain too much Wink


Well... I didn't compile them from my dmd dirs, I compiled the libs from my home directory, then moved them to /usr/lib and the source to /usr/phobos/derelict. Just in case I misunderstood I'll post the file size for libDerelictSDL.a

Code:

ashley@monolith:/usr/lib$ ls -lh libDerelictSDL.a
-rw-r--r-- 1 root root 419K 2006-08-20 12:49 libDerelictSDL.a


Does 419K seem big enough? It looks a little small to me. Does anyone know what it should be?

I'll take a look at the other method on dmedia and see if that helps, but I do have a question about it: will it make my code platform specific, or can it still easily be ported?
Back to top
View user's profile Send private message
Crispy



Joined: 26 Nov 2005
Posts: 67

PostPosted: Wed Aug 23, 2006 5:29 am    Post subject: Reply with quote

Your code will be portable between platforms no matter how you set up dmd/build/Derelict. As long as it works and your import statements are standard then you're fine.

(Unless of course you use platform-specific code, then it won't be portable under any circumstances.)
Back to top
View user's profile Send private message
diepruis



Joined: 20 Aug 2006
Posts: 6

PostPosted: Mon Aug 28, 2006 3:26 am    Post subject: Still no love Reply with quote

Okay.

I followed the tutorial over at DMedia that h3r3tic suggested. You can see it here.
I changed some of the steps to fit my setup, here's what I did differently:

  1. dmd and build is in /usr/bin where they should be
  2. phobos is under /usr/d/src/phobos and derelict under /usr/d/src/ext/derelict
  3. I added -I/usr/d/src/phobos & -L-ldl to /etc/dmd.conf


After doing this I attempted to compile the example program from the above tutorial like so:
Code:

ashley@monolith:~/temp/dertest$ build gl_test.d -I/usr/d/src/ext/
gcc: /usr/d/src/ext/derelict/opengl/gl.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/gltypes.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/glfuncs.o: No such file or directory
gcc: /usr/d/src/ext/derelict/util/loader.o: No such file or directory
gcc: /usr/d/src/ext/derelict/util/exception.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/gl12.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/gl13.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/gl14.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/gl15.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/gl20.o: No such file or directory
gcc: /usr/d/src/ext/derelict/opengl/glx.o: No such file or directory


Adding -op to the command line fixed that, however, now it's giving me these errors:
Code:

ashley@monolith:~/temp/dertest$ build gl_test.d -I/usr/d/src/ext/ -op
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread5startFZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread5startFZv+0xb8): undefined reference to `pthread_create'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread4waitFZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread4waitFZv+0x38): undefined reference to `pthread_join'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread4waitFkZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread4waitFkZv+0xdf): undefined reference to `pthread_cancel'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread5pauseFZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread5pauseFZv+0x13): undefined reference to `pthread_kill'
:std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread5pauseFZv+0x3a): undefined reference to `sem_wait'/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread6resumeFZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread6resumeFZv+0x13): undefined reference to `pthread_kill'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread8pauseAllFZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread8pauseAllFZv+0x40): undefined reference to `pthread_kill'
:std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread8pauseAllFZv+0x7b): undefined reference to `sem_wait'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread4initFkZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread4initFkZv+0x20): undefined reference to `pthread_attr_setstacksize'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread11thread_initFZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread11thread_initFZv+0xd7): undefined reference to `sem_init'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(thread.o): In function `_D3std6thread6Thread12pauseHandlerUiZv':std/thread.d:(.gnu.linkonce.t_D3std6thread6Thread12pauseHandlerUiZv+0x74): undefined reference to `sem_post'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(critical.o): In function `_STI_critical_init':critical.c:(.text+0xb0): undefined reference to `pthread_mutexattr_init'
:critical.c:(.text+0xbf): undefined reference to `pthread_mutexattr_settype'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(monitor.o): In function `_STI_monitor_staticctor':monitor.c:(.text+0x18): undefined reference to `pthread_mutexattr_init'
:monitor.c:(.text+0x27): undefined reference to `pthread_mutexattr_settype'
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/libphobos.a(monitor.o): In function `_STD_monitor_staticdtor':monitor.c:(.text+0x77): undefined reference to `pthread_mutexattr_destroy'
collect2: ld returned 1 exit status


Now what? Could someone please help me? I'm at my wits' end!
Back to top
View user's profile Send private message
antz



Joined: 23 Jul 2006
Posts: 4

PostPosted: Mon Aug 28, 2006 6:04 am    Post subject: Reply with quote

Try to add
Code:
-L-ldl
to the build command instead of putting it in dmd.conf
(ex.:
Code:
build gl_test.d -I/usr/d/src/ext/ -L-ldl
)
and use the -op option in build_common.txt (on a new line) when you compile Derelict with the buildme.d script.
It did the trick for me Wink
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Aug 28, 2006 6:34 am    Post subject: Reply with quote

Hmmm that's curious. It seems like gcc can't find symbols from the pthreads library... -L-lpthreads should fix it
Back to top
View user's profile Send private message MSN Messenger
diepruis



Joined: 20 Aug 2006
Posts: 6

PostPosted: Tue Aug 29, 2006 12:10 pm    Post subject: Still no luck Reply with quote

Thanks for the help guys.

@antz

I did as you said, rebuilt Derelict and put all the .a files in /usr/lib. Then I ran ldconfig, it still doesn't list the files. I didn't think it would though. I removed -L-ldl from dmd.conf and ran build.

No luck, it gave me the same error message as in my post above.


@h3r3tic

Before I tried your solution I deleted the Derelict libraries from /usr/lib, as your method on the site didn't mention copying them there.

Here's the result I got:
Code:

ashley@monolith:~/temp/dertest$ build gl_test.d -I/usr/d/src/ext/ -L"-ldl -lpthreads"
/usr/bin/ld: cannot find -lpthreads
collect2: ld returned 1 exit status


I thought my syntax might be wrong, so I tried this:
Code:

ashley@monolith:~/temp/dertest$ build gl_test.d -I/usr/d/src/ext/ -L-l"dl phtreads"
gcc: phtreads: No such file or directory


Which is strange because libpthreads is installed:
Code:

ashley@monolith:~/temp/dertest$ ldconfig -p | grep pthread
        libpthread.so.0 (libc6, hwcap: 0x8008000000008000, OS ABI: Linux 2.6.0) => /lib/tls/i686/cmov/libpthread.so.0
        libpthread.so.0 (libc6, hwcap: 0x8000000000000000, OS ABI: Linux 2.6.0) => /lib/tls/libpthread.so.0
        libpthread.so.0 (libc6, OS ABI: Linux 2.2.0) => /lib/libpthread.so.0
        libgpgme-pthread.so.11 (libc6) => /usr/lib/libgpgme-pthread.so.11


Is my syntax wrong in some way? Or do you still think it might be libpthread causing the problem?
Back to top
View user's profile Send private message
Crispy



Joined: 26 Nov 2005
Posts: 67

PostPosted: Thu Aug 31, 2006 4:39 am    Post subject: Reply with quote

I'm not familiar with the syntax, but it seems to me like this would be more likely to work: -L-ldl -L-lpthreads
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Thu Aug 31, 2006 7:12 am    Post subject: Reply with quote

... try -L-lpthread
Back to top
View user's profile Send private message MSN Messenger
diepruis



Joined: 20 Aug 2006
Posts: 6

PostPosted: Thu Aug 31, 2006 11:25 am    Post subject: Nyo! Reply with quote

@Crispy

ashley@monolith:~/temp/dertest$ build gl_test.d -I/usr/d/src/ext/ -L-ldl -L-lpthreads
/usr/bin/ld: cannot find -ldl-lpthreads
collect2: ld returned 1 exit status

@h3r3tic
ashley@monolith:~/temp/dertest$ build gl_test.d -I/usr/d/src/ext/ -L-l"dl pthread"
gcc: pthread: No such file or directory

Grrr..... Thanks for the help so far guys. Hope we can get this sorted out...
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Thu Aug 31, 2006 3:59 pm    Post subject: Reply with quote

Why can't you just write it as I put it but try some weird -L-l"foo bar" instead ? o_0
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group