visual-studio 在 Visual Studio 中创建 .lib 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1322473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:54:44  来源:igfitidea点击:

creating .lib file in Visual Studio

visual-studio

提问by Mike D

I feel like an idiot asking such a basic question but for the life of me, I can't find much on this topic.

问这样一个基本问题,我觉得自己像个白痴,但就我的生活而言,我在这个话题上找不到太多东西。

Anyway, how does one go about making a .lib file using Visual Studio (or whatever tool)?

无论如何,如何使用 Visual Studio(或任何工具)制作 .lib 文件?

Let's say I have a project or work space with one .cpp file and .obj in it.

假设我有一个项目或工作空间,其中包含一个 .cpp 文件和 .obj。

TIA, Mike

TIA,迈克

采纳答案by Henrico Dolfing

To create a new static library project

创建一个新的静态库项目

From the File menu, select New and then Project….

从文件菜单中,选择新建,然后选择项目...。

On the Project types pane, under Visual C++, select Win32.

在“项目类型”窗格上的 Visual C++ 下,选择 Win32。

On the Templates pane, select Win32 Console Application.

在模板窗格中,选择 Win32 控制台应用程序。

Choose a name for the project, such as MathFuncsLib, and enter it in the Name field.

为项目选择一个名称,例如 MathFuncsLib,然后在名称字段中输入它。

Choose a name for the solution, such as StaticLibrary, and enter it in the Solution Name field.

为解决方案选择一个名称,例如 StaticLibrary,然后在解决方案名称字段中输入它。

Press OK to start the Win32 application wizard. On the Overview page of the Win32 Application Wizard dialog box, press Next.

按确定启动 Win32 应用程序向导。在 Win32 应用程序向导对话框的概述页上,按下一步。

On the Application Settings page of the Win32 Application Wizard, under Application type, select Static library.

在 Win32 应用程序向导的应用程序设置页面上,在应用程序类型下,选择静态库。

On the Application Settings page of the Win32 Application Wizard, under Additional options, clear the Precompiled header check box.

在 Win32 应用程序向导的“应用程序设置”页上的“其他选项”下,清除“预编译头”复选框。

Press Finish to create the project.

按完成以创建项目。

See herefor more details.

请参阅此处了解更多详情。

回答by erelender

Go to Project->Properties. Under "General" set "Configuration Type" to "Static Library (.lib)". Then under "Linker" change the extension of the Output File to .lib . Then you're good to go. Remember to do these for all your configurations (Debug, Release etc.)

转到项目-> 属性。在“常规”下,将“配置类型”设置为“静态库 (.lib)”。然后在“链接器”下将输出文件的扩展名更改为 .lib 。那你就可以走了。请记住为您的所有配置(调试、发布等)执行这些操作

回答by DanDan

Go into proprties->Configuration Properties->General->Configuration type.

进入属性-> 配置属性-> 常规-> 配置类型。

There you want to choose static library (.lib).

在那里您要选择静态库 (.lib)。

Then you just have to build it.

然后你只需要构建它。

回答by Preet Sangha

look at the project properties. There will be one that says something like output type, you just choose library, as opposed to .exe.

查看项目属性。会有一个说输出类型之类的东西,你只需选择库,而不是.exe。