August 19th, 2003, 09:51 AM
How to make .lib .dll .obj of my functions
I wrote a lot of string functions, I want to use them without recompiling everytime. I tried getting the .obj file but.. they won't compile without a main(). I have the prototypes in X.h, how would I get my functions in a .dll? do I need to make any changes? what about .lib?
August 19th, 2003, 11:41 AM
the reason why compiler complains abt main() is because by default it compiles the source to an executable...
to prevent this, u need to include the "-c" option. This will create a non-executable binary object file.
Using conventional naming, the object file compiled is of file extension ".o"
$ gcc -c mylib.c
this will create by default mylib.o object file.
mylib.c is just a set of library codes and does not contain any main().
To use this object file:
$gcc -o myHelloWorld.exe mylib.o myHelloWorld.c
thils will compile my calling program with the object file...
You can tar multiple object files into a single archived file (usu file extension of ".a") and use that archived file as if its a single object file when compiling with other calling programs...:
$gcc -o myCallingProg.exe myBigLibCollection.a myCallingProg.c
After all this, i must add that my personal preferences after encountering many linkage problems in the past while attempting to compile STLs and porting, I prefer to avoid unnecessary libraries. I would put all my codes in the header files and have all my calling programs to #include them when needed. (its the way sgi stl do it and i like it, just my own preference... )
Hope it helps a little...
Sorrie if it doesnt...
Last edited by siddy; August 19th, 2003 at 11:45 AM.
August 19th, 2003, 01:23 PM
NM, fixed it, was missing a ; ^_^
Last edited by movEAX_444; August 19th, 2003 at 02:01 PM.