I currently have a console project which creates an .exe file; I want it to also create a .lib file so other projects, compiled as DLLs, would be able to call functions from the original project.
I know it is possible, but I couldn't find how to do that. How do I tell the linker to also link a .lib?
The easiest way is to use the "Visual Studio Command Prompt", you'll find it in the Start menu, Microsoft Visual Studio 2010, Visual Studio Tools. Next, run lib.exe with the /def:foo.
Yes, the Core and Utils code will be duplicated. Instead of building them as static libs you can build them as dlls and use anywhere.
The Microsoft Library Manager (LIB.exe) creates and manages a library of Common Object File Format (COFF) object files. LIB can also be used to create export files and import libraries to reference exported definitions.
Posting this just as a reference I know the original post was posted long time ago but this still applies to anyone who needs a solution to this problem.
Go to the project you want to make a .lib file for and follow these steps:
Finally in the Command Line paste this:
@ECHO ON
@ECHO "$(VC_ExecutablePath_x86)\lib.exe" /out:"$(OutDir)$(ProjectName).lib" "$(IntermediateOutputPath)*.obj"
"$(VC_ExecutablePath_x86)\lib.exe" /out:"$(OutDir)$(ProjectName).lib" "$(IntermediateOutputPath)*.obj"
This will call the lib tool to generate the lib file out of the generated object files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With