Summary: Shared library support for Linux is missing
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Timo Westk´┐Żmper <> 2012-04-09 
00:00:21 PDT ---
Shared library creation for Linux via dmd doesn't work.

Here is my latest test:

* test.d:
import std.stdio;
extern (C) {
  void hiD() {
    writeln("hi from D lib");

* main.c
#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
void main() {
    void (*hiD)(void);
    void* handle = dlopen("./", RTLD_LAZY);
    if (handle == NULL) {
        printf("%s\n", dlerror());
    hiD = dlsym(handle, "hiD");
    if (hiD != NULL) {
    } else {
        printf("hiD is null\n");

* Makefile
    #gdc-4.6 -g -c test.d -fPIC -o test.o
    #gdc-4.6 -shared -o -fPIC test.o -lc -nostartfiles
    dmd -g -c test.d -fPIC
    ld -shared -o test.o -lrt -lphobos2 -lpthread
    gcc -g main.c -ldl -lpthread
    rm -rf *.so *.o *.out

With this setup I get

  ./ undefined symbol: _deh_beg

With a fake main method added I get

  make: *** [test] Segmentation fault

This is what I get from gdb

  Program received signal SIGSEGV, Segmentation fault.
  0xb7fd1ed3 in std.stdio.__T7writelnTAyaZ.writeln() 
(_param_0=...) at   /usr/include/d/dmd/phobos/std/stdio.d:1550
  1550        enforce(fprintf(.stdout.p.handle, "%.*s\n",

I am using dmd 2.058 on Ubuntu 11.10 (32 bit)

With gdc I get different errors, but it seems even more difficult 
to get it working.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to