How do I create both a .lib file and an .exe file in Visual C++?

前端 未结 5 1940
后悔当初
后悔当初 2021-02-07 10:51

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

5条回答
  •  故里飘歌
    2021-02-07 11:23

    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:

    1. Right click on the project.
    2. Select Properties.
    3. Select Build Events.
    4. Select Pre-Link Event .
    5. 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.

提交回复
热议问题