Connecting Tech Pros Worldwide Forums | Help | Site Map

using a static library from a static library

Manny Silva
Guest
 
Posts: n/a
#1: Nov 17 '05
Hi,

I would like to create a static library that uses and in effect adds to
another static library. I could simply add functionality to the existing
library, but functionally it doesn't really belong there... that is, the one
library is very inspecific. The Library I need to create will be project
specific, and I prefer not to have to mix the two... in any case, I tried to
create a library that referenced the first library. I added the library
(such_n_such.lib) to the "Additional Dependencies" property, under the
Librarian category in the project properties (I'm using VS2003, btw). Then,
immediately below that, I added the configuration dependent path in the
"Additional Library Directories" property (e.g. -
C:\Code\...\$(ConfigurationName))

Now, before I added a single line of code to the wizard generated
project, it compiled, giving me tons of warnings about such and such already
exists. It appeared to have been trying to build both the .lib file and all
of the .obj files in the directory. And when it was done, the library file
that it built was almost three times the size of the library that I was
trying to include. Now, I know relatively little about staticly linked
libraries, but I was under the impression that when you statically link, it
only brings in the portions of that library that are used... so does anyone
have any idea why I am getting these odd results or what I can do to bring
about the desired results?

--
Thanks in advance for your help,
Manny

Steve Alpert
Guest
 
Posts: n/a
#2: Nov 17 '05

re: using a static library from a static library


When you link with a library, the smallest unit that can be incorporated from
the library is a "compilation unit", normally a .c or .cpp file. You can't pull
in individual functions unless they are the only thing in the unit itself. Is
it practical to make a DLL out of the LIB and do a dynamic load of the DLL and
GetProcAddress() for the functions you want to present from your DLL?

/steveA

Manny Silva wrote:[color=blue]
> Hi,
>
> I would like to create a static library that uses and in effect adds to
> another static library. I could simply add functionality to the existing
> library, but functionally it doesn't really belong there... that is, the one
> library is very inspecific. The Library I need to create will be project
> specific, and I prefer not to have to mix the two... in any case, I tried to
> create a library that referenced the first library. I added the library
> (such_n_such.lib) to the "Additional Dependencies" property, under the
> Librarian category in the project properties (I'm using VS2003, btw). Then,
> immediately below that, I added the configuration dependent path in the
> "Additional Library Directories" property (e.g. -
> C:\Code\...\$(ConfigurationName))
>
> Now, before I added a single line of code to the wizard generated
> project, it compiled, giving me tons of warnings about such and such already
> exists. It appeared to have been trying to build both the .lib file and all
> of the .obj files in the directory. And when it was done, the library file
> that it built was almost three times the size of the library that I was
> trying to include. Now, I know relatively little about staticly linked
> libraries, but I was under the impression that when you statically link, it
> only brings in the portions of that library that are used... so does anyone
> have any idea why I am getting these odd results or what I can do to bring
> about the desired results?
>[/color]


--
Steve Alpert
my email Fgrir_Nycreg @ vqk.pbz is encrypted with ROT13 (www.rot13.org) and spaces

Manny Silva
Guest
 
Posts: n/a
#3: Nov 17 '05

re: using a static library from a static library



--
Thanks in advance for your help,
Manny

Well, it's not impossible, but the goal is to end up with a single
executable that will not rely upon anything external (for the sake of
portability)... but I also need a full install, that doesn't have to be
portable and can be dependent on whatever. Both need to draw functionality
out of a static library that I have, but both will need more functionality
that will be shared. So I thought that the best way to go about that would
be to create a new static library that built on top of the first. In the
install, I would use the new library in an ATL DLL. In the portable app, it
would be linked in.

In the first e-mail I describe my method for creating the new library... and
that is all that I do... without adding a single line of code... the new
library compiles, and I get TONS of warnings (perhaps one per method in the
original library, but that is not for certain) exactly as follows:

cryptlib.lib(rdtables.obj) : warning LNK4006: "void __cdecl
Rijndael_VC60Workaround(void)" (?Rijndael_VC60Workaround@@YAXXZ) already
defined in cryptlib.lib(rdtables.obj); second definition ignored

as if I were including the library twice?? and the original library is
26.8MB (the debug version) - the new one is 50.8MB, again without a single
line of code added... I can't for the life of me understand why this is...

is there some sort of project setting/compiler flag that will cause this
project to do what I want it to do? This really just doesn't make any sense
to me...

Thanks for your help,
Manny


"Steve Alpert" wrote:
[color=blue]
> When you link with a library, the smallest unit that can be incorporated from
> the library is a "compilation unit", normally a .c or .cpp file. You can't pull
> in individual functions unless they are the only thing in the unit itself. Is
> it practical to make a DLL out of the LIB and do a dynamic load of the DLL and
> GetProcAddress() for the functions you want to present from your DLL?
>
> /steveA[/color]
Manny Silva
Guest
 
Posts: n/a
#4: Nov 17 '05

re: using a static library from a static library


Steve,

Thank you much for your help. As it turns out, the answer to my problem
is that a static library can simply use the methods in another static library
without linking to it. Then, any project that links to this library will
have to also link to the other as well, but this is fine.

Thanks again,
Manny


"Steve Alpert" wrote:
[color=blue]
> When you link with a library, the smallest unit that can be incorporated from
> the library is a "compilation unit", normally a .c or .cpp file. You can't pull
> in individual functions unless they are the only thing in the unit itself. Is
> it practical to make a DLL out of the LIB and do a dynamic load of the DLL and
> GetProcAddress() for the functions you want to present from your DLL?
>
> /steveA[/color]
Closed Thread