Include dll into .exe

General FreeBASIC programming questions.
Provoni
Posts: 393
Joined: Jan 05, 2014 12:33
Location: Belgium

Include dll into .exe

Postby Provoni » Jun 11, 2020 19:11

Hey all,

My program uses zlibwapi.dll. Is there a way to include it with the .exe itself so it doesn't need to be included in the program directory?

Thanks
MrSwiss
Posts: 3726
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Include dll into .exe

Postby MrSwiss » Jun 11, 2020 19:14

Nope, sorry, no way for .dll (dynamic link lib) loaded/linked at run time.
Only static lib's are linkable at compile time (included in .exe).
UEZ
Posts: 688
Joined: May 05, 2017 19:59
Location: Germany

Re: Include dll into .exe

Postby UEZ » Jun 11, 2020 20:22

Provoni wrote:Hey all,

My program uses zlibwapi.dll. Is there a way to include it with the .exe itself so it doesn't need to be included in the program directory?

Thanks


Yes for windows at least, it is possible to embed the DLL into the exe and call it directly from the memory. Check this out: http://www.joachim-bauch.de/tutorials/l ... om-memory/
srvaldez
Posts: 2651
Joined: Sep 25, 2005 21:54

Re: Include dll into .exe

Postby srvaldez » Jun 11, 2020 20:27

never tried it but apparently it can be done, here's a purebasic solution https://www.purebasic.fr/english/viewto ... dll+binary
UEZ
Posts: 688
Joined: May 05, 2017 19:59
Location: Germany

Re: Include dll into .exe

Postby UEZ » Jun 11, 2020 20:33

srvaldez wrote:never tried it but apparently it can be done, here's a purebasic solution https://www.purebasic.fr/english/viewto ... dll+binary

Definitely it can be done. I did it using Autoit in several project I made. ;-)
jj2007
Posts: 1962
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Include dll into .exe

Postby jj2007 » Jun 12, 2020 0:12

I have little doubts about that, see How to convert a dynamic dll to static lib? at SOF.

What is certainly possible (and easy to do) is to include the DLL as an RCDATA resource, and to write it to the executable's folder during the first run. In comparison, the PureBasic version posted above may work for some dlls but is ridiculously complicated.

Btw the easiest solution would be to compile the source as a static lib.
srvaldez
Posts: 2651
Joined: Sep 25, 2005 21:54

Re: Include dll into .exe

Postby srvaldez » Jun 12, 2020 0:23

@jj2007
in the link you provided it seems that they are talking about an import lib and not a static lib
Provoni
Posts: 393
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Include dll into .exe

Postby Provoni » Jun 12, 2020 5:28

Thanks for your answers everyone.

UEZ wrote:Definitely it can be done. I did it using Autoit in several project I made. ;-)

Can you give a short run down?
UEZ
Posts: 688
Joined: May 05, 2017 19:59
Location: Germany

Re: Include dll into .exe

Postby UEZ » Jun 12, 2020 7:20

Provoni wrote:Thanks for your answers everyone.

UEZ wrote:Definitely it can be done. I did it using Autoit in several project I made. ;-)

Can you give a short run down?

What do you need exactly?
Provoni
Posts: 393
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Include dll into .exe

Postby Provoni » Jun 12, 2020 7:37

Hey UEZ,

Include a dll into .exe, but if there is not a elegant and simple solution then I will skip it.

Thanks
UEZ
Posts: 688
Joined: May 05, 2017 19:59
Location: Germany

Re: Include dll into .exe

Postby UEZ » Jun 12, 2020 7:56

Provoni wrote:Hey UEZ,

Include a dll into .exe, but if there is not a elegant and simple solution then I will skip it.

Thanks

Afaik, there is no solution for Freebasic yet unless someone is willing to port it to Freebasic, too. For other languages, e.g. AutoIt, yes. I can provide you a sample code but this will be out of scope for this forum providing non Freebasic code.
SARG
Posts: 1230
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Include dll into .exe

Postby SARG » Jun 12, 2020 9:10

Include a dll into .exe, but if there is not a elegant and simple solution then I will skip it.

pefrmdllembed could do the job. However not used/tested.

http://pefrm-units.osdn.jp/pefrmdllembed.html

If you get some difficulty to find an executable I took it from https://www.gtagarage.com/mods/show.php?id=28541 (click on donwload mod)

Don't forget to run your AV on it before executing....
jj2007
Posts: 1962
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Include dll into .exe

Postby jj2007 » Jun 12, 2020 9:28

srvaldez wrote:@jj2007
in the link you provided it seems that they are talking about an import lib and not a static lib
They are talking about several things, and in a fairly confused way even for SOF standards. Of course, an import lib is useless for OP's problem. Converting a DLL into a real static lib, otoh, is a can of worms. The same applies for the attempt to run the code of a DLL from memory: not foreseen by the OS, so you need some dirty hacks to do that.

The cleanest solution is to include the DLL in the installation package. But then OP might run into licensing problems, I suppose. Is hiding it inside the exe the solution?
Provoni
Posts: 393
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Include dll into .exe

Postby Provoni » Jun 13, 2020 7:31

jj2007 wrote:The cleanest solution is to include the DLL in the installation package. But then OP might run into licensing problems, I suppose. Is hiding it inside the exe the solution?

Not a licensing problem. Just want the .exe to be stand alone for worst case scenario.
jj2007
Posts: 1962
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Include dll into .exe

Postby jj2007 » Jun 13, 2020 7:42

Provoni wrote:worst case scenario.
Which is?

Return to “General”

Who is online

Users browsing this forum: No registered users and 12 guests