Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Problem 1

Status
Not open for further replies.

RaKKeR

Programmer
Nov 22, 2004
26
0
0
NL
Hi,

This may be a stupid question, but I'll ask it anyway. Is it possible to merge a bunch of lib-files into one static library that has no dependencies? Let's say I have two libraries lib1.lib and lib2.lib. Lib1 uses lib2 to function correctly. Can I merge lib1 and lib2 into lib3 which has the functionalities of lib1 and which can be used on a pc that lacks lib2?

Thx in advance,

RaKKeR
 
No, there's no linking into libs.

/Per
[sub]
www.perfnurt.se[/sub]
 
So if I want to create a library that can be used by a third party, there's no other choise than to give them the separate files and tell them to link them all with there new program?
 
That's the way. Note for example how many .libs there are included by default when generating, say, a simple console app with the AppWizard.

If you are creating the .lib, and the other libs you wish to link into it are also yours then of course it's only a matter of compiling it all into a single .lib. (or are you trying to distribute other's work as yours?)

You could cram in all into a .dll though (.dll and .exe is almost the same thing), but then you'd get a run-time dependancy (but to a single .lib/.dll pair) rather than just a link time dependancy.



/Per
[sub]
www.perfnurt.se[/sub]
 
If you are creating the .lib, and the other libs you wish to link into it are also yours then of course it's only a matter of compiling it all into a single .lib. (or are you trying to distribute other's work as yours?)

The .lib's are made by myself. But I can't find a way to compile them in one lib. I don't even know if it's possible...

You could cram in all into a .dll though (.dll and .exe is almost the same thing), but then you'd get a run-time dependancy (but to a single .lib/.dll pair) rather than just a link time dependancy.

are you sure all the dependant libs will be compiled in the dll?
 
The .lib's are made by myself. But I can't find a way to compile them in one lib. I don't even know if it's possible

Sure it is possible. Just create a new .lib project and add all required .h/.cpp files to it. Compile.

Example:
Say you have a bunch of source code a.h/a.cpp, b.h/b.cpp.
Today you let a.h/a.cpp compile to a.lib, and b.h/b.cpp compile to b.lib

Make a new project containing all the source a.h/a.cpp and b.h/b.cpp and compile it to a single lib

are you sure all the dependant libs will be compiled in the dll?
Yes. Just as everything required would be linked into an .exe. As I said a .dll and a .exe is alomst the same thing, a .dll contains fully executeable code, basiacally the only difference is that
1) A .dll exports some well-defined dll functions (but a .exe could do this as well)
2) A .exe can be executed by itself, a .dll can not.



/Per
[sub]
www.perfnurt.se[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top