November 29, 2021

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/

November 29, 2021

On Monday, 29 November 2021 at 07:29:35 UTC, Mike Parker wrote:

>

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/

Thanks again for all the responses. For now -- I am simply adding the DLL to the EXE and writing it out to the working directory. Not elegant - but it does work.

import std.stdio;
import std.file;

ubyte[] curlBytes = cast(ubyte[]) import("libcurl.dll");

void main(string[] args)
{
    std.file.write("libcurl.dll", curlBytes);

    // test curl
    import std.net.curl;
    auto content = get("https://httpbin.org/get");
	writeln(content);
	writeln("..DONE");
}

November 29, 2021

On Monday, 29 November 2021 at 14:58:07 UTC, Willem wrote:

>

Thanks again for all the responses. For now -- I am simply adding the DLL to the EXE and writing it out to the working directory. Not elegant - but it does work.

"Programmers are not to be measured by their ingenuity and their logic but by the completeness of their case analysis." - Alan Perlis.

December 01, 2021

On Monday, 29 November 2021 at 14:58:07 UTC, Willem wrote:

>

Thanks again for all the responses. For now -- I am simply adding the DLL to the EXE and writing it out to the working directory. Not elegant - but it does work.

If you intend to distribute it then becareful with this as it might trigger some (if not all) antiviruses under most configurations.

December 01, 2021

On Wednesday, 1 December 2021 at 07:45:21 UTC, bauss wrote:

>

On Monday, 29 November 2021 at 14:58:07 UTC, Willem wrote:

>

Thanks again for all the responses. For now -- I am simply adding the DLL to the EXE and writing it out to the working directory. Not elegant - but it does work.

If you intend to distribute it then becareful with this as it might trigger some (if not all) antiviruses under most configurations.

Huh, I never intended for someone to actually use this :|
Such a thing will never work on macOS for example.

December 01, 2021

On Wednesday, 1 December 2021 at 09:49:56 UTC, Guillaume Piolat wrote:

>

Huh, I never intended for someone to actually use this :|
Such a thing will never work on macOS for example.

You can create an installer rather easily with InnoSetup instead.

1 2
Next ›   Last »