问题
I have a List of 390 Libraries and need to port a software from lab CVI to Visual C. Those dependencies are killing me.
I cant import all of them, that would be overkill - and not all of them are unique and/or can be loaded at all.
Is there an easy way to determine what calls a lib file takes? Are there any editors for this?
回答1:
The Microsoft librarian program LIB.EXE allows you to examine library contents, assuming you are asking about static libraries. It's part of the VC++ distribution, or at least it used to be - I don't use VC++ any more. These are the options available:
Microsoft (R) Library Manager Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
usage: LIB [options] [files]
options:
/CONVERT
/DEBUGTYPE:CV
/DEF[:filename]
/EXPORT:symbol
/EXTRACT:membername
/INCLUDE:symbol
/LIBPATH:dir
/LINK50COMPAT
/LIST[:filename]
/MACHINE:{ALPHA|ARM|IX86|MIPS|MIPS16|MIPSR41XX|PPC|SH3|SH4}
/NAME:filename
/NODEFAULTLIB[:library]
/NOLOGO
/OUT:filename
/REMOVE:membername
/SUBSYSTEM:{NATIVE|WINDOWS|CONSOLE|WINDOWSCE|POSIX}[,#[.##]]
/VERBOSE
回答2:
There is one other thing you might consider doing to reduce the amount of content that you import with a static library. In CVI, open the header file corresponding to the .lib/.dll that you are using. Save this file to a different name.h.
Again, in the editor, edit that file to include only the exported functions you would like to use. Use caution here to prevent editing out functions that may be called by the functions you intend to keep. Once satisfied you have a file representative of what you want, click anywhere in the new name.h file (to make sure it is the active file) and use the menus at the top of the workspace to select Options->Generate DLL Import Library...
A popup file selection dialog box will appear. Using that dialog, navigate to the .dll corresponding to the .lib file you want to generate. If successful, a new name.lib will be created containing only the exported functions you want.
[EDIT] Additionally this will help to avoid COFF incompatibility problems sometimes seen when mixing libraries created in different environments.
来源:https://stackoverflow.com/questions/4461389/how-can-you-examine-lib-files