I wanted to compile the sample C++ program that uses VLC Api, according to the https://wiki.videolan.org/LibVLC_Tutorial/, with my Visual Studio 2012 on Windows 7 x64 (I work with x86 anyway).
In order to obtain a .lib
file, I've followed: https://wiki.videolan.org/GenerateLibFromDll/. I had some problems at the start, but finally I got (I've noticed the warnings):
And I do have my libvlc.lib
created. I've moved it to the folder with my main.cpp
, added the path to Project -> VC++ Directories -> Library directories
as well as added the .lib
file with Add -> existing item
. I also added the Project -> VC++ Directories -> Include Directories
so it points to ...vlc-2.1.5\include
.
I run the clean, rebuild all
on my empty solution.
Unfortunately I got the errors:
1>------ Rebuild All started: Project: Project1, Configuration: Debug Win32 ------
1> Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_new referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_release referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_media_new_location referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_media_release referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_media_player_new_from_media referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_media_player_release referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_media_player_play referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _libvlc_media_player_stop referenced in function _main
1>...\Project1\Debug\Project1.exe : fatal error LNK1120: 8 unresolved externals
Which looks like either something is wrong with my .lib
or its somehow it's not connected in a right way. The compilation works fine, the linking fails.
The full source code of the only .cpp
file in project is an exact copy of the tutorial posted on videolan.org: http://pastebin.com/5gfFVFZd
According to @user1
comment, I've corrected the dumpbin
command (in the screen shot, "libvlc.dill" should be "libvlc.dll"). That was indeed one problem. After the change, I got much more warnings (all of the same type as before, 277 together) and much bigger .def file (15MB, progress). But the output .lib file is exact same size (1.48MB - it's very small .lib) and the linker error with it prevails. So I guess there's still something wrong with the .lib creation.
The .def
file: http://pastebin.com/E81s6dnh
The last lines make me feel uncomfortable:
256 FF 00001CF0 libvlc_vprinterr
257 100 00001790 libvlc_wait
LINK : fatal error LNK1328: missing string table
Check dumpbin
command in the screen shot,
"libvlc.dill" should be "libvlc.dll"
Generally speaking, when all inputs to linker are correct & yet if linker complains then I would look at some lib import #defines specifically. Sometimes, .lib can't just be imported without defining some #DEFINE in the linker input settings which allows the lib to be imported. e.g. IMPORT_X_LIB. Do you have any such import lib #define defined for vlc lib. if yes, you must add those in linker input.