Skip to main content
gamedev.net
🔒 Locked

Combining Static Libraries?

Started by GamerSg Dec 25, 2004 at 7:13 AM 6 replies 1.1k views
Original Post
GamerSg
GamerSg
Whenever we compile our code, all the required code from .lib files is extracted and combined to produce 1 exe. After which the exe no longer requires the .lib file to run. But if i am compiling a library, how do i ensure that all dependancies also get linked and compiled into the output library.
Promit
Promit
If you're compiling a library, it will link any dependencies you tell it to, same as in an EXE.

Be careful about doing this. It's often a better idea to let the EXE's project include all of the necessary things, often because things like choice of runtime library will make or break the link stage.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
chollida1
chollida1
"If you're compiling a library, it will link any dependencies you tell it to, same as in an EXE."

Yes and no, a lib will only include its own code. It won't link in another lib into it. The linking only happens when you build a dll or an exe, then the linker will cause the lib to pull in the other libs it requires.

ie. if you have lib a that depends on lib b and an exe that depends on lib a, you build lib an and b and then you build the exe, you still need lib b when you link it as lib a doesn't have lib b built "into it".

Cheers
Chris
CheersChris
Cedric Perthuis
Cedric Perthuis
I dont' get it i was anonymous... but i did register and login before...
Cedric Perthuis
Cedric Perthuis
there is something wrong with the cookie name of this forum... I need to add my username at the top of the reply again...

I forgot to precize something, it's not as complex to do as what I described. the step "extract the .o" from the .lib isn't necessary.
the librarians allow you to add ALL the .o which are in a certain .lib. You might need to create a specific librarian script. I did some for SN Prodigy librarian. it's easy. You just specify something like
CREATE myLib
ADDLIB timer
ADDLIB draw
END
I am sure there is way to do that with visual either from the command line or from the IDE.

Topic Locked

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

Sign in to reply to this topic.