Re: Making a D library for a C executable

2023-04-28 Thread Jan Allersma via Digitalmars-d-learn
On Thursday, 27 April 2023 at 21:34:17 UTC, Steven Schveighoffer wrote: Also, please include your commands for building the D library so reproduction is possible. -Steve I used to `dub run` to solve the problem, nothing special. My `dub.json` isn't that interesting either, but I'll show it

Re: Making a D library for a C executable

2023-04-28 Thread Jan Allersma via Digitalmars-d-learn
On Thursday, 27 April 2023 at 21:34:17 UTC, Steven Schveighoffer wrote: You may have to link the library second. Sometimes linkers are particular about object order. Hi Steve, Your suggestion worked! Reversing the order solved the problem. I have another problem that I'm facing, but that

Re: Making a D library for a C executable

2023-04-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/27/23 5:29 PM, Jan Allersma wrote: On Thursday, 27 April 2023 at 21:05:00 UTC, Mike Parker wrote: That's a compilation error, not a linker problem. You need to tell the compiler about the function with a prototype: Declaring the function does fix the compiler problem. However, I do get

Re: Making a D library for a C executable

2023-04-27 Thread Jan Allersma via Digitalmars-d-learn
On Thursday, 27 April 2023 at 21:05:00 UTC, Mike Parker wrote: That's a compilation error, not a linker problem. You need to tell the compiler about the function with a prototype: Declaring the function does fix the compiler problem. However, I do get a linker error once I compile that:

Re: Making a D library for a C executable

2023-04-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 April 2023 at 20:32:24 UTC, Jan Allersma wrote: ``` Apparently foo isn't found from the CPP source file. Anyone some ideas on how to solve this? :) That's a compilation error, not a linker problem. You need to tell the compiler about the function with a prototype: ```C++

Making a D library for a C executable

2023-04-27 Thread Jan Allersma via Digitalmars-d-learn
Hello, I see some examples on the internet on how to call C(++) in D. But I want to do it the other way around. Because of (probably) linkage issues, this way seems easier. I have this D code: ``` import std.stdio; int maint() { writeln("Returning some random stuff..."); return 10; }