Difference between revisions of "GenerateLibFromDll"
m (+category) |
m (+{{Example code|for=libVLC}}, format, grammar) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Example code|for=libVLC}} | ||
from: [http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/ http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/] | from: [http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/ http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/] | ||
Line 13: | Line 14: | ||
It can be found within the Visual Studio Tools menu entry: Start / Program Files / Microsoft Visual Studio / Visual Studio Tools / Visual Studio 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 | + | == Extract Symbols == |
Within the command prompt type: | Within the command prompt type: | ||
− | dumpbin /exports " | + | {{prompt|cmd}} dumpbin /exports "{{Path to VLC|windows|dir=y|q=n}}\libvlc.dll" > "{{Path to VLC|windows|dir=y|q=n}}\libvlc.def" |
Edit the libvlc.def file and modify it to get something like this: | Edit the libvlc.def file and modify it to get something like this: | ||
− | |||
EXPORTS | EXPORTS | ||
libvlc_add_intf | libvlc_add_intf | ||
Line 33: | Line 33: | ||
Alternatively, the following command will automatically generate the DEF file: | Alternatively, the following command will automatically generate the DEF file: | ||
− | echo EXPORTS > libvlc.def | + | {{prompt|cmd}} echo EXPORTS > libvlc.def |
− | for /f "usebackq tokens=4,* delims=_ " %i in (`dumpbin /exports " | + | {{prompt|cmd}} for /f "usebackq tokens=4,* delims=_ " %i in (`dumpbin /exports "{{Path to VLC|windows|dir=y|q=n}}\libvlc.dll"`) do if %i==libvlc echo %i_%j >> libvlc.def |
== Generate the .lib == | == Generate the .lib == | ||
Line 40: | Line 40: | ||
Still within the command prompt type: | Still within the command prompt type: | ||
− | lib /def:" | + | {{prompt|cmd}} lib /def:"{{Path to VLC|windows|dir=y|q=n}}\libvlc.def" /out:"{{Path to VLC|windows|dir=y|q=n}}\libvlc.lib" /machine:x86 |
Of course, you'll need to adapt the path according to your configuration. | Of course, you'll need to adapt the path according to your configuration. | ||
− | + | Voilà! You have it, now you can link against libvlc.lib in your program <nowiki>:-)</nowiki> | |
− | [[Category: | + | [[Category:libVLC]] |
Latest revision as of 08:38, 18 March 2019
This page contains example code for libVLC. |
from: http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/
Introduction
To avoid installing and fighting against MSYS and Cygwin, you can just extract exported 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 "%PROGRAMFILES%\VideoLAN\VLC\libvlc.dll" > "%PROGRAMFILES%\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 "%PROGRAMFILES%\VideoLAN\VLC\libvlc.dll"`) do if %i==libvlc echo %i_%j >> libvlc.def
Generate the .lib
Still within the command prompt type:
> lib /def:"%PROGRAMFILES%\VideoLAN\VLC\libvlc.def" /out:"%PROGRAMFILES%\VideoLAN\VLC\libvlc.lib" /machine:x86
Of course, you'll need to adapt the path according to your configuration.
Voilà! You have it, now you can link against libvlc.lib in your program :-)