I am not sure if this even possible, but I am trying to link a static library (.lib) to a dll during compile time, but I am not having any luck.
The main dll contains an export called exportfunc. I am running procmon to monitor rundll32.exe, and I see it attempt to load my.dll from disk, but that's not aligning with what I am trying to accomplish as I am trying to statically link the external functions from my.lib so that it gets resolved at compile time.
Here's how I am generating the .lib file.
# Generate an object file using x86_64-w64-mingw32-gcc
x86_64-w64-mingw32-gcc -c -o myobj.o myprogram.c -I /tmp/include
# Generate dll using x86_64-w64-mingw32-gcc
x86_64-w64-mingw32-gcc -o my.dll -shared -Wall -Wno-pointer-to-int-cast -Os -I ../include -Wl,--enable-stdcall-fixup -Wl,--entry=WinDivertDllEntry myobj.o mydef.def -nostdlib -lkernel32 -ladvapi32 -luser32 -lmsvcrt -include stdio.h
# Generate lib file using x86_64-w64-mingw32-dlltool
x86_64-w64-mingw32-dlltool --dllname my.dll --def windivert.def --output-lib my.lib 2>/dev/null
# Use cl.exe to compile the final dll which statically links the .lb file
cl.exe /W0 /D_USRDLL /D_WINDLL *.c *.cpp /MT /link /DLL /OUT:final.dll my.lib