views:

265

answers:

3

I am new to C/C++. I have a static library (.lib) file created using VC++. (I also have .h file for it). And I need to use this in a C program. Can you please help me doing this?

Thank you, Prashanth.

+2  A: 

Can you clarify if you're trying to build an EXE or a DLL?

What you're looking for is known as static linking. This will take the .lib file and essentially embed it into your application.

You'll need to change your project settings in VC++ to include this file to be one of the files linked into the process. If you give us some more information about the Visual Studio version, we can provide a more specific answer about how to do this.

JaredPar
I don't see anywhere in the question that DLLs are involved.
anon
@Neil, good point, I'll clarify.
JaredPar
Hi, Thank you for your response. I am trying to use a static library (created using VC++) in a C program (exe).
A: 

Note that such static libraries are typically for one compiler (and often even version) only.

Marco van de Voort
I am using VC++ compiler for both.
+1  A: 

Since you're using VC++ for your future C program, go to the project's Configuration Properties (in the Project menu, choose Properties).

Under C/C++->General->Additional Include Directories, add the folder where you have your .h file.

Under Linker->Input->Additional Dependencies, add the name of your .lib file.

comshak