[Windows]_[初级]_[GenerateLibFromDll 从Dll生成lib]

GenerateLibFromDll

from: http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/

Contents

Introduction

To avoid installing and fighting against MSYS and Cygwin, you can just extractexported symbols from libvlc.dll to generate a .lib (libvlc.lib) and link your program against it.And all of this using only with Microsoft Visual Studio Tools!

In case you don't have Visual Studio you can download the free version here Visual Studio Express.

Open a Command Prompt

It can be found within the Visual Studio Tools menu entry: Start / Program Files / Microsoft Visual Studio / Visual Studio Tools / Visual Studio Command Prompt.

Extract Symbols

Within the command prompt type:

dumpbin /exports "C:\Program Files\VideoLAN\VLC\libvlc.dll" > "C:\Program Files\VideoLAN\VLC\libvlc.def"

Edit the libvlc.def file and modify it to get something like this:

EXPORTS
libvlc_add_intf
libvlc_audio_get_channel
libvlc_audio_get_mute
libvlc_audio_get_track
libvlc_audio_get_track_count
libvlc_audio_get_track_description
libvlc_audio_get_volume
...

Alternatively, the following command will automatically generate the DEF file:

echo EXPORTS > libvlc.def
for /f "usebackq tokens=4,* delims=_ " %i in (`dumpbin /exports "c:\Program Files\VideoLan\VLC\libvlc.dll"`) do if %i==libvlc echo %i_%j >> libvlc.def

Generate the .lib

Still within the command prompt type:

lib /def:"C:\Program Files\VideoLAN\VLC\libvlc.def" /out:"C:\Program Files\VideoLAN\VLC\libvlc.lib" /machine:x86

Of course, you'll need to adapt the path according to your configuration.

Et voila! You have it, now you can link against libvlc.lib in your program :-)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值