PHP extension in D

via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 10 14:06:57 PDT 2014


On Thursday, 10 July 2014 at 20:42:41 UTC, Pavel wrote:
> Thank you very much for advice, it helped me :) Here is my 
> build.sh file after all experiments:
>
> #!/bin/sh
> swig -php speedup.i
> dmd -m64 -fPIC -c -L-shared speedup.d
> sed -i "1i char* d_speedUp(char* arg1);" speedup_wrap.c
> gcc `php-config --includes` -fpic -c speedup_wrap.c
> dmd -m64 -shared -defaultlib=libphobos2.so 
> -I/usr/lib/x86_64-linux-gnu speedup_wrap.o speedup.o 
> -ofspeedup.so
>
> Note that we need to insert d_speedUp() function definition in 
> speedup_wrap.c file, otherwise there will be a warning "cast to 
> pointer" and segmentation fault when using compiled speedup.so 
> file:
> speedup_wrap.c: In function ‘_wrap_d_speedUp’:
> speedup_wrap.c:1141:12: warning: cast to pointer from integer 
> of different size [-Wint-to-pointer-cast]
>
> Also I found no mention about rt_term() method in generated 
> files, so my php script works without it.
>    result = (char *)d_speedUp(arg1);

Great! This information might be valuable for others. If you want 
and have the time, maybe you can write a short how-to article for 
the wiki?

http://wiki.dlang.org/Articles


More information about the Digitalmars-d mailing list