简体   繁体   English

使用C中的.lib文件

[英]Using a .lib file from C

I am new to C/C++. 我是C / C ++的新手。 I have a static library (.lib) file created using VC++. 我有一个使用VC ++创建的静态库(.lib)文件。 (I also have .h file for it). (我也有.h文件)。 And I need to use this in a C program. 我需要在C程序中使用它。 Can you please help me doing this? 你能帮我做这个吗?

Can you clarify if you're trying to build an EXE or a DLL? 您能说明您是要构建EXE还是DLL吗?

What you're looking for is known as static linking. 您在寻找什么被称为静态链接。 This will take the .lib file and essentially embed it into your application. 这将使用.lib文件,并将其本质上嵌入到您的应用程序中。

You'll need to change your project settings in VC++ to include this file to be one of the files linked into the process. 您需要在VC ++中更改项目设置,以将该文件包括为链接到该过程的文件之一。 If you give us some more information about the Visual Studio version, we can provide a more specific answer about how to do this. 如果您向我们提供有关Visual Studio版本的更多信息,我们可以提供有关如何执行此操作的更具体的答案。

Since you're using VC++ for your future C program, go to the project's Configuration Properties (in the Project menu, choose Properties). 由于您将VC ++用于将来的C程序,因此请转到项目的配置属性(在“项目”菜单中,选择“属性”)。

Under C/C++->General->Additional Include Directories, add the folder where you have your .h file. 在C / C ++->常规->其他包含目录下,将您的.h文件添加到该文件夹​​中。

Under Linker->Input->Additional Dependencies, add the name of your .lib file. 在“链接器”->“输入”->“其他依赖项”下,添加.lib文件的名称。

请注意,此类静态库通常仅适用于一个编译器(甚至通常是版本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM