I have a Visual Studio C++ project that is making use of uWebSockets. The Visual Studio project file is configured to output a .dll
that is used during runtime of a host executable. I need some of uWebSockets' functionality for my .dll
. I want the project to link to the static libraries of uWebSockets. I used vcpkg
to install it:
vcpkg install uwebsockets:x64-windows-static
And sure enough, after vcpkg does its thing, I can navigate to .vspkg\installed\x64-windows-static\lib
and see the listing of .lib
files that I assume are ready to be satically linked.
uSockets.lib
uv_a.lib
zlib.lib
Back in Visual Studio project configuration window, I set the "Additional Library Directories" to include the .vcpkg\installed\x64-windows-static\lib
and set the "Additional Include Directories" to the \includes
path that vcpkg
installed.
Everything builds as expected with Visual Studio. The problem is that the host app will not load the built .dll
unless the uSockets.dll
and zlib1.dll
files are in the same directory as the running executable. To get those, I had to run vcpkg install uwebsockets:x64-windows
When vcpkg
finished installing that one, there is a bin
directory that contains the .dlls
.
To verify that vcpkg
actually installed true static libs, not "import libraries", I ran the following on the uSockets.lib
file in vcpkg
'sx64-windows-static
dir:
`lib /list uSockets.lib"
And I see this output:
Microsoft (R) Library Manager Version 14.30.30706.0
Copyright (C) Microsoft Corporation. All rights reserved.
CMakeFiles\uSockets.dir\src\bsd.c.obj
CMakeFiles\uSockets.dir\src\context.c.obj
CMakeFiles\uSockets.dir\src\eventing\epoll_kqueue.c.obj
CMakeFiles\uSockets.dir\src\eventing\gcd.c.obj
CMakeFiles\uSockets.dir\src\eventing\libuv.c.obj
CMakeFiles\uSockets.dir\src\loop.c.obj
CMakeFiles\uSockets.dir\src\socket.c.obj
That, to me, says "static lib" as opposed to an import lib. When I run the same command for uSockets.lib
in the x64-windows
install directory, I get the following:
Microsoft (R) Library Manager Version 14.30.30706.0
Copyright (C) Microsoft Corporation. All rights reserved.
uSockets.dll
uSockets.dll
uSockets.dll
uSockets.dll
...
uSockets.dll
uSockets.dll
uSockets.dll
uSockets.dll
That looks like an import lib.
So my question is why are the uSockets.dll and libz1.dll needed at the executable's runtime if they are truly static libraries? When I use vcpkg install uwebsockets:x64-windows-static
why would I still need to place the .dll
's for those libs next to the executable. I thought the point of static libraries was so that you don't need to ship the .dll
s with the application.