Yes, you can do that - its perfectly functional as both a static (.a) and a dynamic lib (.dll) in Windows. It's also just fine as a shared lib (.so) under Linux. (didn't bother to try a static lib in linux) - all code built with Code::Blocks & GCC
I'm pretty tired now, so I'm not really so good at summarising :( So I'll just leave the contents of the files I used.
Part 1 - the library.
libMain.cpp
#include "mySharedLib.h"
mySharedLib.h
#ifndef mySharedLib_h
#define mySharedLib_h
extern int some_function(int t);
class KA
{
public:
void print()
{
some_function(10);
}
};
#endif
Part 2 - The program
main.cpp
#include "../mySharedLib/mySharedLib.h"
#include <stdio.h>
int some_function(int t)
{
printf("You entered %d\n", t);
return t;
}
int main()
{
KA classInst;
classInst.print();
}
Output:
you entered 10