digitalmars.D - Linux shared libraries - I'm confused
- Steve Teale (1/1) Aug 16 2007 I've seen it said that dmd does not support creation of Linux shared lib...
- Steve Teale (2/4) Aug 16 2007 Sorry, more specifically, if I try the GCC approach and then try to dyna...
- Matthias Walter (4/6) Aug 16 2007 AFAIK dmd cannot create position independent code. So, you can link it t...
- Steve Teale (2/11) Aug 16 2007 Hmm, well that's a bit of a show-stopper for Linux coding then isn't it....
- Nicolai Waniek (10/13) Aug 17 2007 I definitley have to say: yes, this is a show-stopper.
- Gregor Richards (3/16) Aug 17 2007 What the hell, people, there's an easy solution: Use GDC.
- Tristam MacDonald (6/28) Aug 17 2007 Not quite as easy as it might be. There seem to be far more pitfalls to
- Gregor Richards (8/40) Aug 17 2007 So long as the standard library is static instead of shared, it will
- Tristam MacDonald (7/52) Aug 18 2007 C'mon man, I didn't mean it like that. Of course there isn't a 2.0
- Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= (3/5) Aug 20 2007 If your 5 1/4" floppies are running out of space, there's an utility cal...
- Nicolai Waniek (7/11) Aug 17 2007 The main reason for this is, that I yet want to use 2.0 features... well...
- Gregor Richards (6/8) Aug 16 2007 It is possible to create a .so file with DMD. It might even occasionally...
- Daniel Truemper (8/10) Aug 16 2007 Can you give an example for creating a shared library on linux with
- Daniel Truemper (6/9) Aug 16 2007 Ups, found it in the new README.software_engineers
- Gregor Richards (3/11) Aug 16 2007 *snaps*, late by a minute ;)
- Daniel Truemper (15/16) Aug 17 2007 Thanks anyways! But I now have another question:
- Daniel Truemper (9/18) Aug 19 2007 Just in case someone is getting the same or a similar error and is
- Gregor Richards (15/26) Aug 16 2007 From README.software_engineers line 155:
I've seen it said that dmd does not support creation of Linux shared libraries, but I've also seen it said that you can use dmd -c to create a .o file, and then use gcc -shared ... to create an so. Can anyone clarify the position here please?
Aug 16 2007
Steve Teale Wrote:I've seen it said that dmd does not support creation of Linux shared libraries, but I've also seen it said that you can use dmd -c to create a .o file, and then use gcc -shared ... to create an so. Can anyone clarify the position here please?Sorry, more specifically, if I try the GCC approach and then try to dynamically load the library, dlopen() reports "/home/teales/d/libgenit.so.1.0.0: undefined symbol: _Dmodule_ref"
Aug 16 2007
Steve Teale Wrote:I've seen it said that dmd does not support creation of Linux shared libraries, but I've also seen it said that you can use dmd -c to create a .o file, and then use gcc -shared ... to create an so. Can anyone clarify the position here please?AFAIK dmd cannot create position independent code. So, you can link it this way but the code is not guaranteed to work. But with gdc you can use -fpic to generate such code. best regards Matthias
Aug 16 2007
Matthias Walter Wrote:Steve Teale Wrote:Hmm, well that's a bit of a show-stopper for Linux coding then isn't it. Am I also correct in thinking that GDC does not support D version 2 yet?I've seen it said that dmd does not support creation of Linux shared libraries, but I've also seen it said that you can use dmd -c to create a .o file, and then use gcc -shared ... to create an so. Can anyone clarify the position here please?AFAIK dmd cannot create position independent code. So, you can link it this way but the code is not guaranteed to work. But with gdc you can use -fpic to generate such code. best regards Matthias
Aug 16 2007
Steve Teale wrote:Hmm, well that's a bit of a show-stopper for Linux coding then isn't it. Am I also correct in thinking that GDC does not support D version 2 yet?I definitley have to say: yes, this is a show-stopper. I'm still waiting for Walter to make it possible to compiler to an .so under Linux... until that, I stopped using D and concentrating on some other projects w/ python. best regards, Nicolai -- .71 nicolai dot waniek at sphere71 dot com
Aug 17 2007
Nicolai Waniek wrote:Steve Teale wrote:What the hell, people, there's an easy solution: Use GDC. - Gregor RichardsHmm, well that's a bit of a show-stopper for Linux coding then isn't it. Am I also correct in thinking that GDC does not support D version 2 yet?I definitley have to say: yes, this is a show-stopper. I'm still waiting for Walter to make it possible to compiler to an .so under Linux... until that, I stopped using D and concentrating on some other projects w/ python. best regards, Nicolai
Aug 17 2007
Gregor Richards wrote:Nicolai Waniek wrote:Not quite as easy as it might be. There seem to be far more pitfalls to getting a working shared library under D than under C. In addition, there is still no 2.0 support in GDC. On a realated note, it would be nice to get libgphobos working as a dynamic library with GDC, and shave a few 100K off of my executables...Steve Teale wrote:What the hell, people, there's an easy solution: Use GDC. - Gregor RichardsHmm, well that's a bit of a show-stopper for Linux coding then isn't it. Am I also correct in thinking that GDC does not support D version 2 yet?I definitley have to say: yes, this is a show-stopper. I'm still waiting for Walter to make it possible to compiler to an .so under Linux... until that, I stopped using D and concentrating on some other projects w/ python. best regards, Nicolai
Aug 17 2007
Tristam MacDonald wrote:Gregor Richards wrote:So long as the standard library is static instead of shared, it will always be more complicated. If the standard library was shared, this would be simple. Oh my god, there's STILL no 2.0 support in GDC after it's existed for almost TWO MONTHS??!?!?! For shame!!! Yeesh.Nicolai Waniek wrote:Not quite as easy as it might be. There seem to be far more pitfalls to getting a working shared library under D than under C. In addition, there is still no 2.0 support in GDC.Steve Teale wrote:What the hell, people, there's an easy solution: Use GDC. - Gregor RichardsHmm, well that's a bit of a show-stopper for Linux coding then isn't it. Am I also correct in thinking that GDC does not support D version 2 yet?I definitley have to say: yes, this is a show-stopper. I'm still waiting for Walter to make it possible to compiler to an .so under Linux... until that, I stopped using D and concentrating on some other projects w/ python. best regards, NicolaiOn a realated note, it would be nice to get libgphobos working as a dynamic library with GDC, and shave a few 100K off of my executables...http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=43626 - Gregor Richards
Aug 17 2007
Gregor Richards wrote:Tristam MacDonald wrote:C'mon man, I didn't mean it like that. Of course there isn't a 2.0 release yet, and since it is a beta and very subject to change, I am not even sure that a GDC 2.0 release is a good idea yet. But if you have a project already using 2.0 features, you *aren't able* to switch to GDC to get shared library support.Gregor Richards wrote:So long as the standard library is static instead of shared, it will always be more complicated. If the standard library was shared, this would be simple. Oh my god, there's STILL no 2.0 support in GDC after it's existed for almost TWO MONTHS??!?!?! For shame!!! Yeesh.Nicolai Waniek wrote:Not quite as easy as it might be. There seem to be far more pitfalls to getting a working shared library under D than under C. In addition, there is still no 2.0 support in GDC.Steve Teale wrote:What the hell, people, there's an easy solution: Use GDC. - Gregor RichardsHmm, well that's a bit of a show-stopper for Linux coding then isn't it. Am I also correct in thinking that GDC does not support D version 2 yet?I definitley have to say: yes, this is a show-stopper. I'm still waiting for Walter to make it possible to compiler to an .so under Linux... until that, I stopped using D and concentrating on some other projects w/ python. best regards, NicolaiCool, I will give this a try.On a realated note, it would be nice to get libgphobos working as a dynamic library with GDC, and shave a few 100K off of my executables...http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmar .D&article_id=43626 - Gregor Richards
Aug 18 2007
Tristam MacDonald wrote:On a realated note, it would be nice to get libgphobos working as a dynamic library with GDC, and shave a few 100K off of my executables...If your 5 1/4" floppies are running out of space, there's an utility called sstrip and if it isn't enough, 'upx --ultra-brute foo.bin' might help too.
Aug 20 2007
Gregor Richards wrote:What the hell, people, there's an easy solution: Use GDC. - Gregor RichardsThe main reason for this is, that I yet want to use 2.0 features... well I'll just wait a few weeks until GDC has those, but until then, I'll stick to another project ;) -- .71 nicolai dot waniek at sphere71 dot com
Aug 17 2007
Steve Teale wrote:I've seen it said that dmd does not support creation of Linux shared libraries, but I've also seen it said that you can use dmd -c to create a .o file, and then use gcc -shared ... to create an so. Can anyone clarify the position here please?It is possible to create a .so file with DMD. It might even occasionally work. But not reliably. It's not exactly an easy process to get one working on GDC either, but it can work. DSSS automates the whole process :) - Gregor Richards
Aug 16 2007
Hi, Gregor Richards wrote:It's not exactly an easy process to get one working on GDC either, but it can work. DSSS automates the whole process :)Can you give an example for creating a shared library on linux with DSSS? I read all readme's from DSSS but can't find it?! I am propably reading over it... Daniel -- "All work but no play makes Jack a dull boy"
Aug 16 2007
Daniel Truemper wrote:Can you give an example for creating a shared library on linux with DSSS? I read all readme's from DSSS but can't find it?! I am propably reading over it...Ups, found it in the new README.software_engineers cheers, Daniel -- "All work but no play makes Jack a dull boy"
Aug 16 2007
Daniel Truemper wrote:Daniel Truemper wrote:*snaps*, late by a minute ;) - Gregor RichardsCan you give an example for creating a shared library on linux with DSSS? I read all readme's from DSSS but can't find it?! I am propably reading over it...Ups, found it in the new README.software_engineers cheers, Daniel
Aug 16 2007
Gregor Richards wrote:*snaps*, late by a minute ;)Thanks anyways! But I now have another question: I just built my library as a shared library, which is working; I'm getting all the so files and links. The I install the library (dsss install) and create a small test app that should include my library. When I build this app, I am getting a ld error: /usr/bin/ld: tmTest: hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) is referenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status Any idea what happend? cheers, Daniel -- "All work but no play makes Jack a dull boy"
Aug 17 2007
I just built my library as a shared library, which is working; I'm getting all the so files and links. The I install the library (dsss install) and create a small test app that should include my library. When I build this app, I am getting a ld error: /usr/bin/ld: tmTest: hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) is referenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit statusJust in case someone is getting the same or a similar error and is confused as I was. The problem is that your library propably requires another library and the you have to tell the linker to explicitly link the 3rd party library in yours. Do this by adding "-L-lc" to your build flags... cheers, Daniel -- "All work but no play makes Jack a dull boy"
Aug 19 2007
Daniel Truemper wrote:Hi, Gregor Richards wrote:From README.software_engineers line 155: When using GDC on GNU/Linux, it is also possible to build shared libraries (.so files). To specify that a shared library should be built, set the 'shared' option in the library's section: [mydpackage] shared You can set the .so file's version extension (the 1.2.3 in .so.1.2.3) with the soversion setting: [mydpackage] shared soversion=3.2.1 - Gregor RichardsIt's not exactly an easy process to get one working on GDC either, but it can work. DSSS automates the whole process :)Can you give an example for creating a shared library on linux with DSSS? I read all readme's from DSSS but can't find it?! I am propably reading over it... Daniel
Aug 16 2007