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 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 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




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





Re: Error: Could not open 'libcmt.lib'

2021-10-26 Thread Willem via Digitalmars-d-learn

On Monday, 25 October 2021 at 20:00:06 UTC, Dr Machine Code wrote:

On Monday, 25 October 2021 at 15:43:06 UTC, Willem wrote:
I was able to resolve above issues by following the install 
guide by DrIggy @


https://www.youtube.com/watch?v=fuJBj_tgsR8

Thanks for posting it.
Willem


A friend of mine was with this issue. We just end up using ldc2 
but would be nice to know the actual fix for dub with dmd



I suspect my initial issue was related to the Visual Studio 2019 
installation. I didn't install the "Desktop development with C++" 
components the first time round. See 1m35sec in video link 
provided.





Re: Error: Could not open 'libcmt.lib'

2021-10-25 Thread Willem via Digitalmars-d-learn
I was able to resolve above issues by following the install guide 
by DrIggy @


https://www.youtube.com/watch?v=fuJBj_tgsR8

Thanks for posting it.
Willem





Error: Could not open 'libcmt.lib'

2021-10-25 Thread Willem via Digitalmars-d-learn
Just starting out new with D.  Up until now I have been using 
Python and a bit of OCaml.


Error when linking: "lld-link: error: could not open 
'libcmt.lib': no such file or directory"


What I did:  I installed the complete D setup in my Windows 10 PC 
-- including VS 2019.


From the command line "C:\D\dmd2vars64.bat" I was able to 
creating a simple program with "dub init hello"


When executing it with "dub run hello" I get following error:

"lld-link: error: could not open 'libcmt.lib': no such file or 
directory"


However -- running "dub run --arch=x86" did work

dmd --version
DMD64 D Compiler v2.098.0-dirty

dub --version
DUB version 1.27.0, built on Oct 10 2021

Searching the forum it appear to be related to MS runtimes... but 
I have not yet been able to resolve it. Any suggestions would be 
greatly appreciated.


Many Thanks.