tags:

views:

119

answers:

1

Hi, I basically making a static library of my own. I have taken my code which works and now put it into a static library for another program to use. In my library I am using another static library which I don't want the people who will be using my API to know. Since, I want to hide that information from them I can't tell them to install the other static library. Anyway, I used the command line Lib.exe to extract and create a smaller lib file of just the obj's I used. However, I get a bunch of "LNK4006 :second definition ignored" linker warnings for each obj I use followed by "LNK4221 no public symbols found;archive member will be inaccessible".

I am doing this work in vs2008 and I am not sure what I am doing wrong. I am using the #pragma comment line in my .cpp file I have also modified the librarian to add my smaller .lib along with its location. my code simply makes calls to a couple functions which it should be able to get from those Obj file in the smaller lib. All my functions are implemented in .cpp file and my header just have the includes of the third party header files and come standard c++ header files. nothing fancy. I have actually no function definitions in there atm. I was going to put the API definition in there and implement that in the .cpp for this static lib that i was going to make. However, I just wanted to build my code before I added more to it. s

Any help would be appreciated. is this a vs2008 configuration issue? or a program issue I am not sure.

thanks for the help!

here is what I researched... http://support.microsoft.com/default.aspx?scid=kb;EN-US;815773

no solution to it there however....

+1  A: 

Even if you extract all objects from the other library and put them in your own library, your users will still be able to see what's in your library and thus see all the object names. In many cases the names of the objects will reveal what's actually the other library you are using.

Instead of distributing your library as a static library, consider distributing it as a DLL. In the DLL you can easily hide all the underlying things and only make public what you want to make public.

Patrick
unfortunately no. This is a requirement I have to follow. I was getting a ton of these warnings. So, I tried to reduce the amount this way by not including obj files that I was not using at all. nevertheless, the issue still stands which is I need to distribute it as a static lib.
@user295030: You can't have both. You can "hide" implementation details, or you can have a static library. If you try, you will get these linker errors. You cannot include a static library in another static library. @Patrick: +1
Billy ONeal
thanks for the response. so if I go the static lib route how can I use those third party obj files as part of "one" static lib?? and i appreciate the answer on the requirement issue. but the issue with regards to how do i get around these lnk4221/lnk4006 is what is killing me at the momnt. I can't seem to get around that? i mean in vs2008 it alows you to add "dependancies" under the librarian tab incase ther are other "libraries". I am not going to offer a dll for sure. They did come back and confirm a static lib. so that is what I have to work with. Does that clear things a bit?
I also found this link and i think the last part applies to me...however i am not using the standard template they use with precompiled headers... http://blogs.msdn.com/vcblog/archive/2009/07/21/linker-warning-lnk4221-and-some-tips-to-avoid-it.aspx this tells me i can include other libs as part of my lib.