4

I have an application that depends on some .dll files. I know if I just make them in the same folder as the .exe file, it would work, but I don't want to leave 30 .dll files with my .exe file. Is there a way I can put them in a folder with my .exe file ?

Or even better, is it possible to compile them and link them with the .exe file to have a standalone file? And no I don't have the static version of these dynamic libraries.

(p.s. the application is written with c, compiled with gcc, mingw win64, and the .dll are from gtk3 libs)

Thank you for reading my question

2501
  • 25,460
  • 4
  • 47
  • 87
Red Star
  • 265
  • 2
  • 15
  • DLL dependencies can be located anywhere on the system PATH or in the working directory (in most cases, the directory containing the executable). DLLs loaded dynamically (i.e. programatically) can be located basically anywhere, since you specify the location in code. – Archimaredes Jan 31 '16 at 13:10
  • 1
    self-extracting archive? – n0p Jan 31 '16 at 13:15
  • ^^ yeah, installer, no problem. – Martin James Jan 31 '16 at 13:27

2 Answers2

1

You have a number of options.

A) get hold of the library files, .lib on windows and statically link with these libraries.

B) It is a bit of a hack but you can attach resources into a Windows executable. This is usually used for strings, icons, that sort of thing, but you could even attach in a binary file. But if you do this you would probably need to generate the dll binaries at program startup and save to eg same folder as your executable. So no point in doing this really, simply distribute in the same folder as your exe. What is the problem doing that? (lookup LoadResource, FindResource, MAKEINTRESOURCE, etc)

C) If you don't want to put the dlls is the same path as your exe you will need to store them in a folder in your system's path env variable. Eg you could copy them to C:\Windows - but due to security that will be harder. You could create your own dll_path and add this path to the env variable as part of the installation of your program.

D) One other variation on C) is that you copy to for example a subdirectory of you exe location, called eg dll_files. Then you use a startup script to launch your program like this:

@echo off
set PATH=%PATH%;<path to dll files>
myprogram.exe
Angus Comber
  • 9,316
  • 14
  • 59
  • 107
  • But I don't have an installation nor want to have one, I want the application to stay portable, but the client doesn't have to search through fifty files to find the executable to launch the program, am I doing things wrong ? – Red Star Jan 31 '16 at 13:32
  • @RedStar if you mean you want something simple like an icon to launch then you are going to need an installer package to put the start icon on the desktop or in programs. If your program consists of say 1 exe and 6 dlls then most tech users can find the exe and launch it. – Angus Comber Jan 31 '16 at 13:35
  • From this I understand that I have two options: either let the .exe file with 50 other .dll file, and the user has to open the whole folder and open the .exe, OR I have to make an installer and then create a desktop shortcut (though It's not really what I ideally wanted, but anyway thanks) – Red Star Jan 31 '16 at 14:23
  • You could put the DLLs *and the executable* in a subfolder and just a launcher in the main folder. There [are some solutions here](http://stackoverflow.com/q/1169556/886887) for using a shortcut, or it could be a simple self-contained executable. – Harry Johnston Jan 31 '16 at 22:27
0

Let's make is simple
download winrar from
www.rarlab.com/download.htm
A) create standalone winrar executable pack your file in archive and execute your main program.
no idea how to create standalone installer guide for you

http://www.groovypost.com/howto/howto/how-to-make-your-own-offline-installers-using-winrar/