Jump to page: 1 2
Thread overview
How to deploy single exe application (?)
Nov 15, 2021
Willem
Nov 15, 2021
pilger
Nov 28, 2021
Willem
Nov 28, 2021
Imperatorn
Nov 28, 2021
Willem
Nov 29, 2021
Imperatorn
Nov 29, 2021
Mike Parker
Nov 29, 2021
Willem
Nov 29, 2021
forkit
Dec 01, 2021
bauss
Dec 01, 2021
Guillaume Piolat
Dec 01, 2021
Guillaume Piolat
Nov 29, 2021
kinke
Nov 29, 2021
kinke
Nov 15, 2021
russhy
Nov 15, 2021
Imperatorn
November 15, 2021

Using D -- I have created a simple command line utility that download some info via a https API and save it in a sqlite3 database file. To use the exe on another windows machine, I need to copy over the relevant sqlite3 and curl DLL files.

Question: Is there a way to create a single .exe with the relevant windows DLL info in there? Can this be done with static linking?

Any feedback / pointers on where to start would be greatly appreciated.

Many Thanks, Willem

November 15, 2021

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

November 15, 2021

On Monday, 15 November 2021 at 21:16:14 UTC, Willem wrote:

>

Using D -- I have created a simple command line utility that download some info via a https API and save it in a sqlite3 database file. To use the exe on another windows machine, I need to copy over the relevant sqlite3 and curl DLL files.

Question: Is there a way to create a single .exe with the relevant windows DLL info in there? Can this be done with static linking?

Any feedback / pointers on where to start would be greatly appreciated.

Many Thanks, Willem

you can statically link libraries just like in other languages

if you use dub it's as easy as this:

"sourceFiles-windows": [
    "../_clibs/glfw3.lib",
]

if you use plain dmd, then it's simple

dmd main.d mylib.lib
November 15, 2021

On Monday, 15 November 2021 at 22:28:41 UTC, russhy wrote:

>

On Monday, 15 November 2021 at 21:16:14 UTC, Willem wrote:

>

Using D -- I have created a simple command line utility that download some info via a https API and save it in a sqlite3 database file. To use the exe on another windows machine, I need to copy over the relevant sqlite3 and curl DLL files.

Question: Is there a way to create a single .exe with the relevant windows DLL info in there? Can this be done with static linking?

Any feedback / pointers on where to start would be greatly appreciated.

Many Thanks, Willem

you can statically link libraries just like in other languages

if you use dub it's as easy as this:

"sourceFiles-windows": [
    "../_clibs/glfw3.lib",
]

if you use plain dmd, then it's simple

dmd main.d mylib.lib

You are correct. But that only works if you got the static libs. If you only have the dynamic libs you have to resort to embedding them (if you don't want to ship them separately).

November 28, 2021

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

November 28, 2021

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?

November 28, 2021

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"]
}


November 29, 2021

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

November 29, 2021

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.

November 29, 2021

On Monday, 29 November 2021 at 03:59:11 UTC, kinke wrote:

>

ldc\curl.exp

Typo, should have been lib\curl.exp.

« First   ‹ Prev
1 2