0

I have the C source code for a library that when used on Windows calls functions from a DLL. Can I compile the library to an object file and statically link it to my application (if I provide the linker with the name of the DLL)? Asked another way, can you create a statically linked executable when the dependencies have dynamically linked dependencies? When I attempted to do it, the DLL functions do not get resolved, but that may just be my (bad) technique. Thanks!

c2po
  • 13
  • 3
  • AFAIK it's not possible in the general case. A simple way out is to embed all the dependencies in some self-extracting exe which then starts your actual executable. – Matteo Italia Jul 24 '17 at 04:21
  • This should work; all of the Windows API _and_ C and C++ runtimes are in DLLs and every 3rd-party lib I've seen on Windows (successfully) uses at least one of those. To be clear, when linking anything (user/main _or_ 3rd-party) to a DLL you need to specify the _import library_ for the DLL not the DLL itself (unlike most Unix where you specify the actual so/sl/etc); exact format (and naming convention) for implib may vary depending on your toolchain, which you didn't identify. – dave_thompson_085 Jul 24 '17 at 05:54

0 Answers0