If I want to add functions to the static library , I am unable to understand how should I do that...........
Create my.lib
polib.exe -out:my.lib obj1.obj
Add obj2.obj obj3.obj
polib.exe my.lib obj2.obj obj3.obj
Thank you Sir
Based on your directions I was able to create my library file and modify it too.
But please Sir help me in one more issue.
To use that function from library file I need a header file. For that I wrote the prototype of that function and saved it with '.h' extension but when I include that file , this error displays :
POLINK: error: Unresolved external symbol 'fact'.
So please Sir help me in this issue.I shall be highly grateful to you.
Do you included that lib too?
To linker options
or
#pragma comment(lib, "my.lib")
Yes Sir I included that but it did not work.
Sir for your convenience I want to tell you what I did So that you can correct me........
Sir I am new to programming So I must have done several several mistakes so please don't get annoyed...You may scold me but do correct me.
1. First of all I wrote a function to calculate factorial of a number as :
int fact(int num)
{
int i,f=1;
for(i=1;i<=num;i++)
f=f*i;
return(f);
}
2. Then I build it and a file fact.obj was created. Using this file I created a library file "fact.lib". I saved this file in pelles C library itself.
3. Then I created a header file as :
#ifndef fact_file
#define fact_file
int fact(int);
#endif
4. Then I saved that file with '.h' extension in the 'include' folder of pellesC in program files in c drive.
5. Then to use that function , I wrote a program as :
#include<stdio.h>
#include<fact.h>
int main()
{
int a,b;
a=6;
b=fact(a);
printf("%d",b);
}
6. Since the location of header file is standard I didnt use these quotes " ".Instead I used < >.
7. Then I selected project options>linker and there i included fact.lib .
8. Now If I build the program it gives the error as I told you earlier.
I could be calling convention problem.#ifndef fact_file
#define fact_file
int __cdecl fact(int);
#endif
Look at example project.
Thankyou So much Sir for taking pain.......I am highly grateful to you :)