Hi all,
my first question is why does a static library rely on a executable to be compiled? I'm trying to create a simple static library and this is my program source:
#include <windows.h>
int SampleAddInt(int i1, int i2);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
int hi=1,hi2=2;
SampleAddInt(hi, hi2);
return 0;
}
So first I compiled the program without the "SampleAddInt(hi, hi2);" and used it to compile the static library.
I used the default static library when creating one with code blocks:
int SampleAddInt(int i1, int i2)
{
return i1 + i2;
}
// A function doing nothing ;)
void SampleFunction1()
{
// insert code here
}
// A function always returning zero
int SampleFunction2()
{
// insert code here
return 0;
}
I linked the compiled library to the program, and I can't compile the main program with the "SampleAddInt(hi, hi2);" getting this error: undefined reference to `SampleAddInt(int, int)'|
Does anybody know why this error happens?