Re: How to compile Phobos with other D code to create a shared library?

2021-06-05 Thread data pulverizer via Digitalmars-d-learn
On Friday, 4 June 2021 at 15:19:17 UTC, bachmeier wrote: It requires an R package if you want to call D functions from R. You need to link to R itself if you want to do something like pass a vector from R to D and then access that data from D. Since R is aware of the location of all the

Re: How to compile Phobos with other D code to create a shared library?

2021-06-04 Thread bachmeier via Digitalmars-d-learn
On Friday, 4 June 2021 at 15:33:32 UTC, Alain De Vos wrote: Dub is probably not much of a help :) That's right. I typically don't use Dub when I'm calling D functions from R. It's the only way you can use a Dub package like Mir, though, so that's why you might want it to generate a dub.sdl

Re: How to compile Phobos with other D code to create a shared library?

2021-06-04 Thread Alain De Vos via Digitalmars-d-learn
Dub is probably not much of a help :)

Re: How to compile Phobos with other D code to create a shared library?

2021-06-04 Thread bachmeier via Digitalmars-d-learn
On Friday, 4 June 2021 at 07:26:53 UTC, data pulverizer wrote: Thanks. Looks like I have some more reading to do. I did know about embedr, but I saw it had dependencies and I wanted a standalone and fully transparent D solution. It requires an R package if you want to call D functions from

Re: How to compile Phobos with other D code to create a shared library?

2021-06-04 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 2 June 2021 at 23:23:58 UTC, bachmeier wrote: Are you aware of my embedr project, which handles all that for you, and does a lot of other stuff? https://embedr.netlify.app If you want to do it yourself, you can see the boilerplate you need to add to call a shared library from R

Re: How to compile Phobos with other D code to create a shared library?

2021-06-02 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 18:18:35 UTC, data pulverizer wrote: Doing `Runtime.initialize` is working with Julia but not yet R, I'm getting a clock/GLIBC error ``` Error in dyn.load("rbasic.so") : unable to load shared object 'code/rbasic.so': lib/x86_64-linux-gnu/librt.so.1: undefined

Re: How to compile Phobos with other D code to create a shared library?

2021-06-02 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 2 June 2021 at 17:49:49 UTC, Steven Schveighoffer wrote: What's happening is that the dynamic linker is trying to resolve that symbol, but cannot find it in the given library. Try `ldd code/rbasic.so` and see if it tells you the things it is looking for. Many times, you will

Re: How to compile Phobos with other D code to create a shared library?

2021-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/21 2:18 PM, data pulverizer wrote: Doing `Runtime.initialize` is working with Julia but not yet R, I'm getting a clock/GLIBC error ``` Error in dyn.load("rbasic.so") :   unable to load shared object 'code/rbasic.so':   lib/x86_64-linux-gnu/librt.so.1: undefined symbol:

Re: How to compile Phobos with other D code to create a shared library?

2021-06-01 Thread data pulverizer via Digitalmars-d-learn
Doing `Runtime.initialize` is working with Julia but not yet R, I'm getting a clock/GLIBC error ``` Error in dyn.load("rbasic.so") : unable to load shared object 'code/rbasic.so': lib/x86_64-linux-gnu/librt.so.1: undefined symbol: __clock_nanosleep, version GLIBC_PRIVATE ``` do I need to

Re: How to compile Phobos with other D code to create a shared library?

2021-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/31/21 5:46 PM, data pulverizer wrote: On Monday, 31 May 2021 at 21:26:15 UTC, Steven Schveighoffer wrote: You need to call it wherever you think it might not have been called yet. It's reentrant, so if you call it more than once, it will only initialize once, and count how many times

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 31 May 2021 at 21:46:09 UTC, data pulverizer wrote: Something interesting is using arrays. I can see that if you instantiate an array within the D function using `new`, for instance Passing one of those to a C function is iffy anyway because the C function can hide it from the

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread data pulverizer via Digitalmars-d-learn
On Monday, 31 May 2021 at 21:26:15 UTC, Steven Schveighoffer wrote: You need to call it wherever you think it might not have been called yet. It's reentrant, so if you call it more than once, it will only initialize once, and count how many times you have to call `Runtime.terminate`.

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/31/21 5:20 PM, data pulverizer wrote: On Monday, 31 May 2021 at 21:01:19 UTC, Steven Schveighoffer wrote: ticksPerSecond is initialized in the runtime just before static constructors are run. See

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread data pulverizer via Digitalmars-d-learn
On Monday, 31 May 2021 at 21:01:19 UTC, Steven Schveighoffer wrote: ticksPerSecond is initialized in the runtime just before static constructors are run. See https://github.com/dlang/druntime/blob/2d8b28da39e8bc3bc3172c69bb96c35d77f40d2a/src/rt/dmain2.d#L130 Are you calling

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/31/21 4:41 PM, data pulverizer wrote: On Monday, 31 May 2021 at 20:32:11 UTC, kinke wrote: On Monday, 31 May 2021 at 19:21:52 UTC, data pulverizer wrote: ldc2 jbasic.d -O3 -link-defaultlib-shared --betterC --boundscheck=off -nogc -shared -of=jbasic.so The problem is almost certainly

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread data pulverizer via Digitalmars-d-learn
On Monday, 31 May 2021 at 20:32:11 UTC, kinke wrote: On Monday, 31 May 2021 at 19:21:52 UTC, data pulverizer wrote: ldc2 jbasic.d -O3 -link-defaultlib-shared --betterC --boundscheck=off -nogc -shared -of=jbasic.so The problem is almost certainly `-betterC`, which disables linking against

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread kinke via Digitalmars-d-learn
On Monday, 31 May 2021 at 19:21:52 UTC, data pulverizer wrote: ldc2 jbasic.d -O3 -link-defaultlib-shared --betterC --boundscheck=off -nogc -shared -of=jbasic.so The problem is almost certainly `-betterC`, which disables linking against Phobos and druntime.

How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread data pulverizer via Digitalmars-d-learn
Hi, I am trying to compile D code to a shared library to be called by another language (in this case Julia). I can get a basic call to work but I can't call functions that use Phobos (I have no idea how to compile against it). I have found some documentation