Re: std.socket tutorials? examples?

2023-04-29 Thread Jan Allersma via Digitalmars-d-learn
On Thursday, 4 October 2018 at 13:07:30 UTC, bauss wrote: Not exactly a tutorial or a walkthrough, but I'll try to explain basic usage of std.socket using an asynchronous tcp server as example. So I tried to code the example as described. After the program is at ```d auto clientResult = Soc

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 a

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 is

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: ```b

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; } ex

Re: CMake and D

2022-08-06 Thread Jan Allersma via Digitalmars-d-learn
On Saturday, 6 August 2022 at 13:52:28 UTC, Jan Allersma wrote: I forgot that I have to add some DUB dependencies. So I have to use `dub` instead of `dmd`. My strategy is to 1) Create a D function which will be called in C++. 2) Build a static library containing the D function (using `dub buil

Re: CMake and D

2022-08-06 Thread Jan Allersma via Digitalmars-d-learn
I forgot that I have to add some DUB dependencies. So I have to use `dub` instead of `dmd`. My strategy is to 1) Create a D function which will be called in C++. 2) Build a static library containing the D function (using `dub build`). 3) Build an executable file with CMake. However, I get an

Re: CMake and D

2022-08-06 Thread Jan Allersma via Digitalmars-d-learn
On Thursday, 4 August 2022 at 20:59:50 UTC, Johan wrote: On Thursday, 4 August 2022 at 20:29:30 UTC, Jan Allersma wrote: So something goes wrong with linking, but I dont know what. Execute `dmd -v` on some test program. It will output the linker line at the end of the output, the line starti

CMake and D

2022-08-04 Thread Jan Allersma via Digitalmars-d-learn
Hello, I am trying to compile an application with both C++ and D source code. First I have `main.d`: ``` extern (C++) void init(); extern (C++) void draw(int row, int column, int x, int y); extern (C++) void render(); void main() { init(); draw(3, 3, 0, 0); draw(3, 3, 2, 2);