1

When I build my project in debug for 32 arch I get a .dll file in the debug folder which is needed to run the executable, is there any way to embed the .dll file inside the executable

statically linking I linked the libraries in the project linker/input section and added to include directories in c++ section all the header files but I still get the .dll file which I have to copy to the destination folder in order for the executable to work

link I already asked a similar question and tried statically linking the library

The only thing I noticed is that the executable is bigger, 233kb old size after linking it is 1500kb and I still get the .dll

  • ***is there any way to embed the .dll file inside the executable*** You could do that but it would be complicated and you would likely have to extract the dll and your real executable first anyways. Basically you would be building your own installer executable that would extract your application's executable and dlls first to a temporary folder then launch your executable. – drescherjm May 19 '21 at 16:24
  • Can you elaborate more on that ,where to look, any resources – packetsniffer May 19 '21 at 16:26
  • 1
    It will be far easier to use NSIS installer than create your own. However the idea is create a small program with binary resources that contain your application executable and required dll as binary resources in the .rc file. This small program would run extract the 2 files to the temporary folder then launch your executable from the temporary folder. – drescherjm May 19 '21 at 16:26
  • 1
    Related: [https://www.codeproject.com/Articles/4221/Adding-and-extracting-binary-resources](https://www.codeproject.com/Articles/4221/Adding-and-extracting-binary-resources) – drescherjm May 19 '21 at 16:29
  • I found loadLibrary that loads a dll but this does not embed the dll in the executable file am I right? – packetsniffer May 20 '21 at 01:16
  • LoadLibrary allows you to use a dll differently and dynamically load a dll file after the program is loaded. This requires that you restructure your program and the the way you use the dll. It also has nothing to do with embedding. You will have to handle that as a separate step. – drescherjm May 20 '21 at 01:41
  • This may help explain how you would have to change the dll usage: [https://stackoverflow.com/questions/8696653/dynamically-load-a-function-from-a-dll](https://stackoverflow.com/questions/8696653/dynamically-load-a-function-from-a-dll) – drescherjm May 20 '21 at 01:43
  • According to your description, whether you want to dynamic load the DLL? If so, I suggest you could refer to the link: https://learn.microsoft.com/en-us/windows/win32/dlls/using-run-time-dynamic-linking – Jeaninez - MSFT May 20 '21 at 06:12
  • My goal is to have the dll embedded in the exe for distribution purposes , [This](https://www.youtube.com/watch?v=_TZ5WiUNxbE) guy claims that using multi-thread debug for the runtime library compiles to a single file but i still get the dll files, LoadLibrary has to look for dll files in the current folder this does not help if you are creating a single exe deployment – packetsniffer May 20 '21 at 11:20
  • LoadLibrary has nothing to do with embedding. – drescherjm May 20 '21 at 13:06

0 Answers0