Click here to Skip to main content
13,003,589 members (61,495 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello once again,

I'm coding an static library and there is a one class.
But I don't understand why all the member variables and methods (all variables are private) are visible in generated lib file. Even the paths and project command line can be found there. As-well there is a lot other "unneeded" information. I have seen few Visual Studio static libraries stripped of all that stuff.

Please avoid comments of type "You will have to live with that". The most radical solution is using the dll to export only specified symbols + exe protector to get rid off all the other informations.

Thank you for help.
Posted 2-Sep-11 7:03am
Philippe Mori 2-Sep-11 18:56pm
I would think that common programmers don't bother with that and professionnal libraries would often export C style function and have a C++ wrapper in header file.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The library file needs to have that information since the header file you distribute for clients to use that class would also have the private variables and functions.

I would guess the libraries you've seen that do not include that information are using the pimpl-idiom (aka Opaque Pointer) to hide the underlying implementation details for their exported classes.

See: Effective C++ (3rd ed) Item 29
See Also: GoTW #28 The Fast Pimpl Idiom[^]

Philippe Mori 2-Sep-11 19:00pm
Effectively, create a wrapper class (or even a C style wrapper) and export only stuff that need to be exported... By the way it should be a dynamic library also...
Paul Heil 2-Sep-11 19:09pm
Yes, that's correct.
It will work fine for dynamically loaded libraries, too
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

How about the option /PDBSTRIPPED ? Any good for your purposes?
MSDN - "/PDBSTRIPPED (Strip Private Symbols)"[^]
Paul Heil 2-Sep-11 19:10pm
That's for pdb files. He's concerned with .lib (COFF) files.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170626.1 | Last Updated 2 Sep 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100