Skip to main content
gamedev.net
🔒 Locked

Creating a .lib

Started by Rah 11 replies 300+ views
Original Post
Rah
Rah
Hi all, I am currently writing my basic game engine (handles all windows stuff as well as dx etc.). As I intend to use this for future games, I''d like to compile it into a .lib and be able to just include this and a header in each project. How would I go about compiling the source into a .lib (ala dx)? Is this a simple task or does it require a restructure of the code? Any limitations? Any pointers would be greatly appreciated, Cheers, Russ.
MadZorg
MadZorg
Hi there...
I assume you are using MSVC++ 6.0. In case you are, just create a new "Static Link Library" project. Put all of your .cpp files in the project and compile it. That will give you a .lib file. Then link the .lib file to your game project and include a header file which prototypes all of the functions in the .lib file. I hope you understand what i mean....

-René
Xeee
Xeee
i''m using borland C++ 5.02 , and i want to know , how to make .lib file from a header i have?
thanks

...Xeee
xee..
Arild Fines
Arild Fines
Header files don''t go into libraries.

Psalm 137:9: "Happy shall he be, that taketh and dasheth thy little ones against the stones."
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
kmsixpence
kmsixpence
I got a q, whats the point of a library. Does it run faster than header/cpp files? It looks and sounds cool but what use is it?
Null and Void
Null and Void
quote:
Original post by kmsixpence
I got a q, whats the point of a library.

If it''s just a static library: To make your package available in an easily usable format for other users. For dynamic libraries (the ones that use DLL''s) it''s almost a must . They hide a whole lot of initialization code from the end programmer.

quote:
Original post by kmsixpence
Does it run faster than header/cpp files?

Dynamic libraries are marginally slower (not much, however) than static libraries. Static libraries are just as if you had the code in your own project.


[Resist Windows XP''s Invasive Production Activation Technology!]
kmsixpence
kmsixpence
Okay. I think i''m gonna go try to create a few right now. :->
DanG
DanG
quote:

Dynamic libraries are marginally slower (not much, however) than static libraries. Static libraries are just as if you had the code in your own project.



Yes DLL''s are slightly slower, however it is incredibly marginal and i wouldn''t want the poster to get the wrong idea (this is by no means anything against you Null and Void). DLL are very useful and the speed issue is rarely a deal. DLLs are on the computer once, so the computer must have the DLL to run the program. This means you can cut down on program size if you think the person will have the DLL (or you include it and at least make the .exe smaller). ALso DLLs CAN (though many arn''t) be language neutral, if done in the correct fashion. I don''t think libraries can. Further more DLLs can be changed and still be used by the program without a single change, provided you didn''t change the interface. This is a very powerful feature for many things. Programs using libraries have to be relinked if there are any changes. You can see the use of DLLs in speed critical places like the DirectX components (each group is in a DLL, more or less). They can update the DLLs without affecting old programs (very useful).

One more clarification, libraries aren''t entirely like have the stuff in your code (nothing agaist Null and Void, he is ABSOLUTELY correct for his intention). Code libraries cannot be seen without hard reverse engineering, so the code itself (not the headers) is safe from being copied. Libraries are faster, but not by alot. If you at all willing, i recommend using DLLs and componenting you Engine so you can change parts to go faster or work better, so on. It is a really good strategy.

THere is my long winded post.

RELIGION IS THE ROOT OF ALL EVIL
Ambassador: Mr. Bush are you stoned or just really, REALLY dumb?Pres. Bush - I assure you I am not stoned.
Zeblar Nagrim
Zeblar Nagrim

I tried to to what MadZorg explained but I get this error:

Dice.obj : error LNK2001: unresolved external symbol "public: __thiscall CPnt::~CPnt(void)" (??1CPnt@@QAE@XZ)
Dice.obj : error LNK2001: unresolved external symbol "public: __thiscall CPnt::CPnt(void)" (??0CPnt@@QAE@XZ)

when I try to make a lib.

This is what I did:
1. Create a static library in MSVS6.0 (dont use precompiled header files).
2. Added a class simple class that I have made called "CPnt".
3. Execute program.
4. Open another win32 program.
5. Added the lib in the settings dialog box.
6. Added the search path to the lib and the include file in the option dialog box.



Zeblar Nagrim, Lord of Chaos
Kaijin
Kaijin
What exactly is the effect of a precompiled header file and how do you go about creating one?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.