0

I am using MinGW to create a dll and everything works fine. Yet, when I use the dll in my projects, it needs other dlls to work. How can I embed other dlls to my dll. I know that while compiling I need *.lib files but how can be this statically compiled. What I have done is

gcc -shared -static -o filename.dll somefiles.c .... -Lc:/directoryOfLibrary -llibfile

this command successfully creates a filename.dll and I can use it in my program provided that depended dlls are in the same folder.

Secondly, I am using some gtk libraries like glib and my dll needs libglib-2.0.dll, but in lib folder of gtk there are glib-2.0.lib and libglib-2.0.dll.a. Which one to use in order to statically compile?

Gorkem Polat
  • 94
  • 2
  • 11
  • You cannot embed DLLs inside another DLL. You need the source files to create a single DLL, but unless you have good reasons, you shouldn't do that – z̫͋ Apr 29 '14 at 11:45
  • The point of dll is to have them separately so each can be updated individually and loaded at runtime. Why do you want to embed them all in a single file? – Shahbaz Apr 29 '14 at 11:48
  • Side note: due to the very intelligent design of Windows, it's very common that all software come with their own copy of the required dlls (so there's a huge amount of duplicate dlls). It's _normal_ if you also include all the hundreds of dlls your application needs to run and ship them with your software. – Shahbaz Apr 29 '14 at 11:49
  • I just want to merge them in one DLL file instead of using multiple DLL files because they will be only used in one program. Ok, DLLs can not be embedded but for each DLL file there is also .lib files, I think those .lib files can be statically linked to the main DLL so that there will be single DLL that can work independently – Gorkem Polat Apr 29 '14 at 11:55
  • In addition if you plan to distribute your DLL without the source, you are not allowed to do that for both Glib and Gtk since they are licensed under the LGPL – z̫͋ Apr 29 '14 at 12:13
  • @z̍̄̒ͪ̚ no it is not for distribution, I am just curious about statically compiling on command windows – Gorkem Polat Apr 29 '14 at 12:30
  • [This](http://stackoverflow.com/questions/15852677/static-and-dynamic-shared-linking-with-mingw) should help – z̫͋ Apr 29 '14 at 12:45

0 Answers0