My present goal is compiling, say, the SQLite library (C-language), statically linked with dependencies on Windows with MSVC Build Tools. I want to get a single DLL file, which may only depend on the core Windows/VC components, such as kernel32 or VC runtime. SQLite library has several extensions with external dependencies, for example, Zipfile/zlib or ICU/ICU. I want to enable these extensions with all necessary code statically linked in the sqlite3.dll file. I can compile it with dynamic linking just fine, but it requires separate dll dependency files, which is what I want to avoid.
Micorosoft has a basic tutorial Walkthrough: Create and use a static library, but I do not see clear instructions on how to do it from the MSVC Build Tools command line. My understanding is that to link a dependency statically, a static library file .lib is required. At the same time, import libraries also have the .lib extension.
I have several questions:
- How can I tell if a given .lib file is an import library or a static library? (I am interested in specific instructions, probably involving some command-line MS Build or Windows Resource Kit tools.)
- How do I create a static library vs. an import library from the command line given a single source file, say, SQLite3.c having no external dependencies?
- Is that correct that if all dependencies are provided as static libraries, the MS linker will create a statically linked dll automatically? (Say, I enable the Zipfile extension in SQLite, build a static zlib library according to instructions for the previous question, and provide it as a dependency to MS Build Tools linker.) Or are there special flags to request static linking?