D for sciencetific scripting / rapid protoryping
Prokop Hapala
prokophapala at gmail.com
Tue Oct 22 08:23:11 UTC 2019
On Tuesday, 22 October 2019 at 08:04:32 UTC, Arun Chandrasekaran
wrote:
> On Tuesday, 22 October 2019 at 07:51:16 UTC, Arun
> Chandrasekaran wrote:
>> On Tuesday, 22 October 2019 at 07:40:01 UTC, Prokop Hapala
>> wrote:
>>> [...]
>>
>> If you are building individual files, use ldc2 with
>> --link-defaultlib-shared flag:
>>
>> arun at home-pc:/tmp$ cat a.d
>> void main() { import std; writeln("Hai"); }
>> arun at home-pc:/tmp$ ldc2 a.d
>> arun at home-pc:/tmp$ ldd a
>> linux-vdso.so.1 (0x00007fff6395b000)
>> libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2
>> (0x00007f1ec91ea000)
>> libpthread.so.0 =>
>> /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1ec91c7000)
>> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
>> (0x00007f1ec9078000)
>> libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
>> (0x00007f1ec905e000)
>> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
>> (0x00007f1ec8e6d000)
>> /lib64/ld-linux-x86-64.so.2 (0x00007f1ec92c4000)
>> arun at home-pc:/tmp$ ldc2 a.d --link-defaultlib-shared
>> arun at home-pc:/tmp$ ldd a
>> linux-vdso.so.1 (0x00007ffcbda7f000)
>> libphobos2-ldc-shared.so.88 =>
>> /home/arun/.bin/ldc2-1.18.0-linux-x86_64/bin/../lib/libphobos2-ldc-shared.so.88 (0x00007f1b57be8000)
>> libdruntime-ldc-shared.so.88 =>
>> /home/arun/.bin/ldc2-1.18.0-linux-x86_64/bin/../lib/libdruntime-ldc-shared.so.88 (0x00007f1b57abc000)
>> libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
>> (0x00007f1b57a84000)
>> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
>> (0x00007f1b57893000)
>> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
>> (0x00007f1b57744000)
>> libpthread.so.0 =>
>> /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1b57721000)
>> librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1
>> (0x00007f1b57714000)
>> libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2
>> (0x00007f1b5770e000)
>> /lib64/ld-linux-x86-64.so.2 (0x00007f1b58067000)
>> arun at home-pc:/tmp$
>
> If you want similar behavior with dub, here is a sample dub.json
>
> arun at home-pc:/tmp/test$ cat dub.json
> {
> "authors": [
> "Arun"
> ],
> "copyright": "Copyright © 2019, Arun",
> "description": "A minimal D application.",
> "license": "proprietary",
> "dflags-ldc": ["-link-defaultlib-shared"],
> "name": "test"
> }
> arun at home-pc:/tmp/test$
>
> Dub settings can be at times intimidating, but still give it a
> read https://dub.pm/package-format-json#build-settings
Thank you Arun, that is very helpful!
Do you have also some example which use some other than default
library ?
I see there is quite comprehensive description how to use dmd
with dynamic libraries
https://dlang.org/articles/dll-linux.html
But there is nothing how to integrate it with dub and deb.json (I
really like DUB, it's one of the best improvements over C/C++
enviroment I noticed)
Also where is RDMD in the equation? I really like the idea run
binary programs like:
#!/usr/bin/env rdmd
import std.stdio;
void main(){
writeln("Hello, world!");
}
But I cannot find any documentation how to use rdmd with any
libraries/dependencies and dub.json ? Not even statically linked,
not to say dynamic.
More information about the Digitalmars-d-learn
mailing list