使用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,下载

http://download.csdn.net/detail/viewlolcs/8197589

或下载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

参考文章:

Stdcall and DLL tools of MSVC and MinGW

 
还有另外一种说法,供参考:

mingw中没有reimp.exe、dumpbin.exe、pexports.exe

2014-09-19 20:01YAWANGZHIWEN | 浏览 721 次
我下载了mingw4.6.2并安装好,但是里面缺少好些执行文件,比如题目中所说的几个,哪位大哥能把bin下面完整的exe文件发送一份啊,感激不尽。
请发送至403929665@qq.com
分享到:

 
举报| 2014-09-19 21:06

提问者采纳

 
  1. reimp已过时,mingw4.6.2中lib和vc的lib是通用的。

  2. dumpbin和pexports是vc专有的,mingw本身就没有 不过有其它可代替的工具。

追问:
那我也安装了VS,为什么在命令行里面调用的时候提示,reimp不是外部或内部命令之类的话啊?
追答:
reimp已经取消了啊,没有这个东西了。只有老版本的mingw才有。现在mingw可以直接使用vc的lib。
追问:
那您可不可以告诉我生成.so文件用的什么命令啊。
看之前的帖子就用到刚刚说的那些命令。之前没有接触过这些东西。
追答:
mingw现在生成的是通用dll  直接编译成dll即可,这个没变。
g++.exe -c md5dllmain.cpp -o md5dllmain.o -I"C:/Programming/MinGW/include" -DBUILDING_DLL=1
dllwrap.exe --output-def libmd5dll.def --driver-name c++ --implib libmd5dll.a md5dllmain.o -L"C:/Programming/MinGW/lib" --no-export-all-symbols --add-stdcall-alias -o md5dll.dll
以上是个例子。
提问者评价
谢谢!

http://blog.csdn.net/libaineu2004/article/details/47783637

Qt下使用的静态链接库------ *.lib转化为mingw使用的.a格式的静态库的更多相关文章

  1. mingw qt(可以去掉mingwm10.dll、libgcc_s_dw2-1.dll、libstdc++-6.dll的依赖,mingw默认都是动态链接gcc的库而TDM是静态链接gcc库,tdm版本更好用。用aspack压缩没有问题。qt本身不使用异常处理)good

    原文地址:mingw qt作者:孙1东 不使用Qt SDK,使用mingw编译qt源代码所遇问题及解决方法: configure -fast -release -no-exceptions -no-r ...

  2. 静态链接和动态链接库混用导致的链接错误LINK2005

    对于一个静态链接库L.lib,它的使用者app.exe会静态链接L.lib,意思是app.exe会将L.lib中的代码(app需要的部分,例如函数定义,类的定义等等)链接到app.exe中.   而对 ...

  3. Linux下动态链接库和静态链接库

    第一部分:编译过程 先了解一下linux下C代码的编译过程,C代码的编译,一般分成四个阶段,包括:预编译,编译,汇编和链接,这四个阶段的分工是 预处理过程,负责头文件展开,宏替换,条件编译的选择,删除 ...

  4. Qt 共享库(动态链接库)和静态链接库的创建及调用

    前言: 编译器 Qt Creator, 系统环境 win7 64 位 1.创建共享库: 新建文件或项目->选择 Library 和 c++ 库->选择共享库->下一步(工程名为 sh ...

  5. linux下动态链接库.so文件 静态链接库.a文件创建及使用

    转摘网址为:http://www.cnblogs.com/fengyv/archive/2012/08/10/2631313.html Linux下文件的类型是不依赖于其后缀名的,但一般来讲:    ...

  6. lib静态链接库,dll动态链接库,h文件

    最近在弄摄像头,发现我在调用摄像头自带的函数的时候,库没连接上,于是经过高人指点,学习了一下lib静态链接库,dll动态链接库来补充一下自己的基础知识. 一.首先我们来介绍一下lib静态链接库. li ...

  7. Linux下 静态链接库 和 动态链接库

    先来说说C/C++编译过程 编译: 检查语句符号定义,将C/C++代码翻译生成中间语言. 链接: 将中间代码整合,生成可执行的二进制代码. 简单的说,库文件都是一种特殊的中间语言文件,静态库还是一种特 ...

  8. 动态链接库dll,静态链接库lib, 导入库lib

    转载地址:http://www.cnblogs.com/chio/archive/2008/08/05/1261296.html 目前以lib后缀的库有两种,一种为静态链接库(Static Libar ...

  9. 动态链接库dll,导入库lib,静态链接库lib

    目前以lib后缀的库有两种,一种为静态链接库(Static Libary,以下简称“静态库”),另一种为动态连接库(DLL,以下简称“动态库”)的导入库(Import Libary,以下简称“导入库” ...

随机推荐

  1. ACM2114_S[I](1^3+2^3+3^3)

    #include<iostream> using namespace std; int main() { __int64 n,m,i,j,sum; while(cin>>n) ...

  2. JavaScript 随机数函数

    Math.random()*(m-n)+n random函数语法 Math.random();   random函数返回值 返回0和1之间的伪随机数,可能为0,但总是小于1,[0,1) 返回10-20 ...

  3. Android-自定义PopupWindow

    PopupWindow在应用中应该是随处可见的,很常用到,比如在旧版本的微信当中就用到下拉的PopupWindow,那是自定义的.新版微信5.2的ActionBar,有人已经模仿了它,但微信具体是使用 ...

  4. 华为OJ:2041 放苹果

    这道题难点不在于代码怎么写,而是思路怎么想. 感觉一般这样的题要么你理好一个思路要么你最后总结出一个公式,要么你自己模拟它的运作方式,用迭代,或者递归的方式来做. 有点像我们曾经学的排列组合. 对于m ...

  5. 【iOS开发之静态库、动态库】

    什么是库? 库 就是程序代码的集合, 是共享程序代码的一种方式,库一般分两类:开源库和闭源库.github中共享一般是开源库:闭源库分为:静态库和动态库,闭源库不开放源代码,是经过编译的二进制文件,一 ...

  6. mvc自带的异步表单提交

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  7. rhel6.4 using centos source

    rhel 默认的 yum 依赖于 rhn,要注册收费才能 update,改用 centos 的源: rpm -e yum* --nodeps rpm -qa | grep yum | xargs rp ...

  8. 学习Android NestedScroll

    NestedScrollingChildHelper 这是一个用于实现子视图嵌套滚动的辅助类,并提供对Android 5.0之前版本的前兼容. View要作为嵌套滚动中的Child,要在构造方法中实例 ...

  9. SQL Server 如何创建定时作业

    在做SQL server 管理时,往往需要每日执行定时任务,但是如果每天都去人工执行,非常不方便,而且一般定时操作,都应该是在数据库压力不大时,一般是在夜间.所以我们需要创建定时作业来代替人工的执行定 ...

  10. iOS_SN_UITableView的优化

    1.提前计算并缓存好高度(布局),因为heightForRowAtIndexPath:是调用最频繁的方法. 2.异步绘制,遇到复杂界面,遇到性能瓶颈时,可能就是突破口. 3.滑动时按需加载,这个在大量 ...