D with gmp via swig

Oliver oliver.ruebenkoenig at web.de
Sun Aug 14 04:29:48 PDT 2011


Hello I am trying to get to a gmp interface for D2. I have some trouble to get
that to work, however. Perhaps someone has an idea what I am doing wrong. I
must admit I am not sure this is a D issue or a swig issue or something else.

The interface file for swig

cat gmpd.i
%module gmpd
%{
#include "gmp.h"
%}

%include "gmp.h"


A main with a call to gmpd

cat main.d
import std.stdio;
import gmpd;

void main() {
        writeln("Hello");
}

This is what I do then:
/usr/local/swig-204/bin/swig -I/usr/include/ -d -d2 gmpd.i

/opt/usr/local/bin/gdc -c main.d
/opt/usr/local/bin/gdc -c gmpd.d
/opt/usr/local/bin/gdc -c gmpd_im.d

/opt/usr/local/bin/gdc -c gmpd_wrap.c
/opt/usr/local/bin/gdc main.o -oa.out gmpd.o gmpd_im.o gmpd_wrap.o -lgmp

I get messages of the type:

/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/bin/ld:
__gmp_set_memory_functions: TLS definition in gmpd_im.o section .tbss
mismatches non-TLS reference in gmpd_wrap.o
gmpd_wrap.o: could not read symbols: Bad value
collect2: ld returned 1 exit status


I have tried dmd and/or gcc (for the wrapper compilation and linking) but no joy.
 Also -fPIC did not help.

Thanks,
Oliver


More information about the Digitalmars-d-learn mailing list