Qt下使用的静态链接库------ *.lib转化为mingw使用的.a格式的静态库 【转载】

12 篇文章 0 订阅
3 篇文章 0 订阅

使用MinGW附带的工具reimp.exe,该工具一般在MinGW in目录下,其readme文档在MinGWdoc eimp目录下,

方法很简单,比如:

C:CodeBlocksMinGWlibdx9>reimp d3d8.lib

就会生成一个“libd3d8.a”文件,这个文件就可以让基于MinGW的编译器链接使用了。

我用这个方法成功的把DirectX9c的.lib库转化成了.a库,并在CodeBlocks下编译成功了其生成的dx项目,

但是有三个.lib文件无法通过这个方法转换:DxErr.lib、DxErr8.lib、DxErr9.lib,估计其他方法,

但似乎没有他们也不影响DX9c库的使用,先这样,需要的话再想办法吧。

还有一个办法,来源是:

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

不知道是否可行,可以试试。

    GCC和VC都使用COFF格式,所以VC中的.obj .lib与gcc用的.o .a是一样的(在WINDOWS下),只是扩展名不一样,通常你只要改一下名称就OK啦!不过有些库不行,因为库中的代码可能会用到一些编译器专有的特性,用VC做的.lib可能在gcc下没法通过编译(缺少符号),反之亦然。

reimp的readme文档内容如下:

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 the
corresponding .DEF file(s) that it feeds to `dlltool' that creates the
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         use for dlltool
--as              use for assembler

The `--dump-symbols' option makes `reimp' use a quick method for
finding imported symbols and sending the names of found symbols to
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
should 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. By
using the `keep-case' option `reimp' will use exactly the case of the
DLL imported from when creating an import library. KERNEL32.dll will
generate libKERNEL32.a and not libkernel32.a as it would 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 of
the `--only-def' and `--dump-symbols' options. You probably want to
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

如果没有reimp

下载mingw-utils
http://sourceforge.net/projects/mingw/files/MinGW/Utilities/mingw-utils/mingw-utils-0.3/mingw-utils-0.3.tar.gz/download

下载mingw-utils-0.3.tar.gz,解压,将其中的reimp copy至MinGW的bin目录下。


使用reimp和dlltool
进入cmd下
cd c:/mysql/lib/opt

reimp -d libmysql.lib

dlltool -k -d libmysql.def -l libmysql.a

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值