开发者

How can you examine lib files?

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 开发者_JAVA百科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?


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


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. Caution: Do not edit 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.

One additional side benefit of limiting the number of exports is that it will help to avoid COFF incompatibility problems sometimes seen when mixing libraries created in different environments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜