Re: How to deploy single exe application (?)
On Sunday, 28 November 2021 at 22:45:29 UTC, Willem wrote: // load sdl string uuid = randomUUID().toString(); string filename = format("SDL2-%s.dll", uuid); string depacked = buildPath(tempDir(), filename); std.file.write(depacked, sdlBytes); DerelictSDL2.load(depacked); // load curl string uuid2 = randomUUID().toString(); string filename2 = format("libcurl-%s.dll", uuid2); string depacked2 = buildPath(tempDir(), filename2); std.file.write(depacked2, curlBytes); DerelictSDL2.load(depacked2); `DerelictSDL2.load()` cannot load curl. It is not a generic dll loader. It only loads SDL and doesn't know anything about curl or any other library. In order to dynamically load curl like this, you need a binding that supports it, i.e., a binding that declares the curl API as function pointers and knows how to load them from the DLL. Also, DerelictSDL2 is no longer maintained. Please use bindbc-sdl for new projects: http://bindbc-sdl.dub.pm/
Re: How to deploy single exe application (?)
On Monday, 29 November 2021 at 03:59:11 UTC, kinke wrote: `ldc\curl.exp` Typo, should have been `lib\curl.exp`.
Re: How to deploy single exe application (?)
On Sunday, 28 November 2021 at 16:08:20 UTC, Willem wrote: Is it possible to distribute an .exe file without the required libcurl DLL? LDC ships with a static curl library - `lib\curl_a.lib`. IIRC, you'll also need to export the curl symbols from the .exe for std.net.curl consumption, by adding `ldc\curl.exp` in the compiler command-line too.
Re: Payload Details with std.net.curl:post
On Sunday, 28 November 2021 at 07:27:35 UTC, ikod wrote: On Sunday, 28 November 2021 at 01:06:45 UTC, Kyle Ingraham wrote: On Saturday, 27 November 2021 at 22:18:48 UTC, ikod wrote: On Saturday, 27 November 2021 at 20:31:16 UTC, Kyle Ingraham Hi Kyle, ``` object.Exception@C:\Users\Kyle Ingraham\AppData\Local\dub\packages\requests-2.0.2\requests\source\requests\streams.d(890): ssl connect failed: certificate verify failed ``` I checked the issues page for `hunt-http` and saw that there were similar reports there from Windows users (I have not verified them myself). I did not try `vibe-http` because the callback interface in the docs wasn't one that grabbed me. Do you have tips on why I might be getting that exception? I'm guessing I need to point `requests` at a trust store. Yes, trust store location can be the problem. I hope you checked this readme sections: [windows-ssl-notes](https://github.com/ikod/dlang-requests#windows-ssl-notes) and [ssl-settings](https://github.com/ikod/dlang-requests#ssl-settings). It is difficult to answer without having more details, but I recently fixed a bug that could lead to a similar problem on 32-bit systems (regardless of OS). If this is your case, then you can try to use the latest commit from the github. Anyway, it would be nice if you create an issue on github and post more details there, so that I can try to reproduce the problem. I had read those sections but couldn't figure out which combination of certificates and function calls would make a difference for my URL. I found https://pki.goog/repository/ which has links to all certificates relevant to Google URLs. I worked my way down the certificate chain and the call that worked was: ```D auto rq = Request(); rq.sslSetCaCert(r"gtsr1.pem"); ``` That certificate is for one of Google's root CAs but not the root of the certificate chain. With that combination my request worked and the payload was delivered successfully. I was also able to see the payload that had been sent in my request which was my motivation for starting this thread in the first place. I think my trouble here was mostly due to my limited familiarity with SSL verification. I ended up using a CA certificate and the method made available was `sslSetCaCert`. A bit obvious when I look back. I had not used it at first because it was referenced as being needed for vibe.d and when perusing `requests` I thought that it wasn't being called for my setup. Glad to have a working setup now. Thank you ikod for stopping by and asking about my experiences outside of `std.net.curl`. P.S. `openssl s_client -connect :443` was useful for viewing the certificate chain.
Re: How to deploy single exe application (?)
On Sunday, 28 November 2021 at 22:45:29 UTC, Willem wrote: On Sunday, 28 November 2021 at 16:12:42 UTC, Imperatorn wrote: [...] I think so ... below is my test program. It executes OK - but it is not using the imported libcurl dll. Many Thanks. [...] https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order
Re: How to deploy single exe application (?)
On Sunday, 28 November 2021 at 16:12:42 UTC, Imperatorn wrote: Did you try the import solution? I think so ... below is my test program. It executes OK - but it is not using the imported libcurl dll. Many Thanks. == app.d ``` import std.stdio; import std.uuid; import std.file; import std.path; import std.string; import derelict.sdl2.sdl; ubyte[] sdlBytes = cast(ubyte[]) import("SDL2.dll"); ubyte[] curlBytes = cast(ubyte[]) import("libcurl.dll"); void main(string[] args) { // load sdl string uuid = randomUUID().toString(); string filename = format("SDL2-%s.dll", uuid); string depacked = buildPath(tempDir(), filename); std.file.write(depacked, sdlBytes); DerelictSDL2.load(depacked); // load curl string uuid2 = randomUUID().toString(); string filename2 = format("libcurl-%s.dll", uuid2); string depacked2 = buildPath(tempDir(), filename2); std.file.write(depacked2, curlBytes); DerelictSDL2.load(depacked2); // test curl import std.net.curl; auto content = get("https://httpbin.org/get;); writeln(content); writeln("..DONE"); } ``` == dub.json ``` { "dependencies": { "derelict-sdl2": "~>2.1.4" }, "name": "add-sdl", "stringImportPaths": ["./dll"] } ```
Re: Debugging D code with GDB
On Saturday, 27 November 2021 at 14:17:11 UTC, Eduard Staniloiu wrote: Hello, I'm trying to use `gdb` to debug D binaries, but I'm having trouble accessing the methods of a struct or class. It seems that `gdb` doesn't see them. Given the following simple example ``` // test.d struct S { int x; void myPrint() { writefln("x is %s\n", x); } } void main(string[] args) { S s; } ``` Compile the source file with debug simbols (`dmd -g test.d -of=test`) and open the binary with gdb (`gdb test`) and run the following ``` break _Dmain # break at D entry point run ptype s type = struct test.S { int x; } print s.myPrint() Structure has no component named myPrint. ``` As you can see, when I try to access the `myPrint()` method I get the error "Structure has no component named myPrint." DMD doesn't emit this information. GDB can't work miracles when the compiler isn't pulling its own weight.
Re: Debugging D code with GDB
On Sunday, 28 November 2021 at 16:44:38 UTC, russhy wrote: On Sunday, 28 November 2021 at 14:53:17 UTC, user1234 wrote: ... there is a plugin to demangle things automatically https://github.com/ANtlord/gdb-ddemangle That's off-topic. The point here is that you can (unfortunately) **only** evaluate the call using the mangled form, it's not about transforming the output. Actually what would be useful is a plugin the mangle the call in custom expression before passing it to gdb ;)
Re: Debugging D code with GDB
On Sunday, 28 November 2021 at 14:53:17 UTC, user1234 wrote: ... there is a plugin to demangle things automatically https://github.com/ANtlord/gdb-ddemangle
Re: How to deploy single exe application (?)
On Sunday, 28 November 2021 at 16:08:20 UTC, Willem wrote: On Monday, 15 November 2021 at 21:53:04 UTC, pilger wrote: [...] Many Thanks all for the responses. Reminder of my requirements: - I am using d2sqlite3 and std.net.curl in a Windows 64 D program - Want to create a single exe file that I can distribute to other people without the need to distribute the related DLL's [...] Did you try the import solution?
Re: How to deploy single exe application (?)
On Monday, 15 November 2021 at 21:53:04 UTC, pilger wrote: On Monday, 15 November 2021 at 21:16:14 UTC, Willem wrote: Any feedback / pointers on where to start would be greatly appreciated. https://p0nce.github.io/d-idioms/#Embed-a-dynamic-library-in-an-executable Many Thanks all for the responses. Reminder of my requirements: - I am using d2sqlite3 and std.net.curl in a Windows 64 D program - Want to create a single exe file that I can distribute to other people without the need to distribute the related DLL's Progress to date: sqlite3: - I found a static compiled version of sqlite3.lib. So I am now able to link sqlite3 into my exe. curl: - No luck with curl yet. - As per comment from @pilger -- I got the sample DerelictSDL2 program working after adding "derelict-sdl2": "~>3.0.0-beta" to dub.json and "import derelict.sdl2.sdl;" to app.d - I see the exe is bigger, so I assume it it added to the relevant curl DLL -- but the separate Windows DLL file is still required to execute the exe. So it is not finding the imported DLL file! Is it possible to distribute an .exe file without the required libcurl DLL? Many Thanks
Re: Debugging D code with GDB
On Saturday, 27 November 2021 at 14:17:11 UTC, Eduard Staniloiu wrote: Hello, I'm trying to use `gdb` to debug D binaries, but I'm having trouble accessing the methods of a struct or class. It seems that `gdb` doesn't see them. [...] Looking forward to your answers, Edi [0] - https://sourceware.org/bugzilla/show_bug.cgi?id=22480 Hello, while I never evaluate calls during debugging I've managed to find a way : you can call the mangled name so for ```d #!dmd -g module a; import std.stdio; struct S { int myPrint(){return 8;} } pragma(msg, S.myPrint.mangleof); int main(string[] args) { S s; return 0; } ``` in gdb CLI ```bash p (int) _D1a1S7myPrintMFZi(s) $1 = 8 ``` works. Note that for some reasons writefln causes a crash, that's why I've modified the example. The problem is that my workaround does not scale better than your.