views:

73

answers:

3

Hi,

I am currently providing a static library using vs2008. I am in the process of building my static library. However, since I am using another static library is there a way that i package this as a single static library. The reason here is that they will be calling functions in my library that depend on that other static library (.lib). I am not sure how to go about doing that and need some help with that.

+1  A: 

Look under project properties | Configuration Properties | Librarian | General

Put the name of the library (.lib) file you want to add to your library under "Additional Dependencies"

You may also have to set the "Additional Library Directories" setting so that it can find the library.

Ferruccio
when i do that and just do a build i see WARNING LNK4221: no public symbols found, archive member will be inaccessible. followed by a ton of LNK4006 warnings for all the obj files in that library. clues? The static library file that I am adding has a ton of obj files in it and since i assume I am not using or making references to all of those in my code thus i am thinking perhaps it would be ok to ignore these warnings...and thus not sure how to get rid of these warnings as I i like to keep a very clean build.
A: 

VC++ includes a command line library manager called lib.exe. It can me used to combine both object files and library files into a single library.

It may not be relevant to your case, but in some cases combining a third-party library to your own and distributing that as a library rather than a final application, (or in the case of many open source licenses, the source), may contravene the license terms for that library. So apply some caution in such cases.

Clifford
A: 

Here is one way:

  1. Find out all the object files in the static library. That can be done by running the command lib STATICLIB /list
  2. Extract each object listed. You must give the exact name from step 1 (lib STATICLIB /extract:.\debug\foo.obj)
  3. You can then add all the objects extracted form step 2 into your library
R Samuel Klatchko
where do you run this command from? vs2008 command line? and what would be the path? where the actual project is?
@user295030 - yes, lib.exe would be run from the command line. The path of the command depends on where you installed Visual Studio - easiest thing is to run the "Visual Studio Command Prompt" to get your environment configured.
R Samuel Klatchko
and this is better than using the acutal .lib that i am putting there as a dependency to my library?
@user295030 - no, it's not better. Personally I would recommend having the user of your library link both static libraries. But I'm willing to let you know how you can do it the way you asked in your question.
R Samuel Klatchko