How to convert library files from msvc format (. Lib) to mingw format (.)

Source: Internet
Author: User

 
Convert the library file from msvc format (. Lib) to mingw format (..
Favorites

Use the reimp.exe tool provided by mingw. this tool is generally located in the mingw/bin directory, and its readme file is located in the mingw/doc/reimp directory,

The method is simple, for example:

C:/codeblocks/mingw/lib/DX9> reimp d3d8. Lib

A "libd3d8. A" file is generated, which can be used by the mingw-based compiler link.

 

Using this method, I successfully converted the. Lib library of directx9c into the. A library, and compiled the generated DX project under codeblocks,

However, there are three. Lib files that cannot be converted using this method: dxerr. Lib, dxerr8.lib, and dxerr9.lib. Other methods are estimated,

However, it seems that none of them will affect the usage of the dx9c library. If necessary, try again.

 

There is another way, the source is:

Http://topic.csdn.net/t/20040721/11/3195357.htm

I don't know if it is feasible. You can try it.

Both GCC and VC use coff format, so. obj. Lib in VC and. O used by GCC
. A is the same (in Windows), but the extension is different. You only need to change the name to OK! However, some libraries do not work, because the code in the library may use some unique features of the compiler.
. Lib made with VC may not be compiled (without symbols) in GCC, and vice versa.

 

 

The reimp readme document is as follows:

 

Readme for reimp
======================

* Overview

'Reimp 'is a tool to convert Microsoft's new-style (short) Import
Libraries to import libraries for Win32 ports of GNU tools (mingw32,
Cygwin ).

'Reimp 'reads an MS import library and writes all imports to
Corresponding. Def file (s) that it feeds to 'dltool' that creates
Import library.

* Invocation

Usage: reimp [Options] implib

Options:
-S, -- dump-Symbols dump symbols to stdout
-D, -- only-Def only create. Def files
-C, -- keep-case keep case in lib *. A file names
-- Dlltool <Name> use <Name> for dlltool
-- As <Name> use <Name> for example

The '-- dump-symbols' option makes 'reimp 'use a quick method
Finding imported symbols and sending the names of found symbols
Stdout. If the input Library contain non-imported symbols they will be
Listed as well. The output symbols will have all decoration preserved
(I. e '_' Will prefix most symbols), So if you feed it to dlltool you
Shocould strip leading underscores. For example

Echo exports> imp. Def
Reimp imp. Lib | SED's/_ // '> imp. Def
Dlltool-k -- def imp. def -- output-lib libimp. A -- dllname imp. dll

The '-- only-Def' option makes 'reimp 'stop after generating the. Def
File (s ).

By default 'reimp 'converts all output library names to lower-case.
Using the 'Keep-case' option 'reimp 'will use exactly the case of
DLL imported from when creating an import library. kernel32.dll will
Generate libkernel32.a and not libkernel32.a as it wocould be default.

* Notes on mixed Libraries

If an input Library contain regular objects (non-imports, I. e code and
Data) 'reimp 'will write out those objects unless you specify one
The '-- only-Def' and '-- dump-symbols' options. You probably want
Include those objects as well in the generated library. 'reimp'
Doesn't do that automatically so you have to do it manually using
'Ar ', like this

Reimp imp. Lib # This generates several. O or. OBJ files.
Ar RCS libimp. A *. OBJ # add them to library

* Contact information

URL: http://www.acc.umu.se /~ Anorland/gnu-win32/

Anders norlander <anorland@hem2.passagen.se
>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.