Re: How to deploy single exe application (?)

2021-12-01 Thread Guillaume Piolat via Digitalmars-d-learn
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.


Re: How to deploy single exe application (?)

2021-12-01 Thread Guillaume Piolat via Digitalmars-d-learn

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.


Re: How to deploy single exe application (?)

2021-11-30 Thread bauss via Digitalmars-d-learn

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.


Re: How to deploy single exe application (?)

2021-11-29 Thread forkit via Digitalmars-d-learn

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.


Re: How to deploy single exe application (?)

2021-11-29 Thread Willem via Digitalmars-d-learn

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");
}

```


Re: How to deploy single exe application (?)

2021-11-28 Thread Mike Parker via Digitalmars-d-learn

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 (?)

2021-11-28 Thread kinke via Digitalmars-d-learn

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 (?)

2021-11-28 Thread kinke via Digitalmars-d-learn

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: How to deploy single exe application (?)

2021-11-28 Thread Imperatorn via Digitalmars-d-learn

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 (?)

2021-11-28 Thread Willem via Digitalmars-d-learn

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: How to deploy single exe application (?)

2021-11-28 Thread Imperatorn via Digitalmars-d-learn

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 (?)

2021-11-28 Thread Willem via Digitalmars-d-learn

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: How to deploy single exe application (?)

2021-11-15 Thread Imperatorn via Digitalmars-d-learn

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:

```json
"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).


Re: How to deploy single exe application (?)

2021-11-15 Thread russhy via Digitalmars-d-learn

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:

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

if you use plain dmd, then it's simple

```
dmd main.d mylib.lib
```


Re: How to deploy single exe application (?)

2021-11-15 Thread pilger via Digitalmars-d-learn

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



How to deploy single exe application (?)

2021-11-15 Thread Willem via Digitalmars-d-learn
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