带有 C++ 的 VLC Api - .lib 的链接器错误(即使我已将它添加到我的 VC++ 项目中) [英] VLC Api with C++ - linker error for .lib (even when I've added it to my VC++ project)
问题描述
我想根据
根据 @user1
评论,我已经更正了 dumpbin
命令(在屏幕截图中,libvlc.dill"应该是libvlc.dll").那确实是一个问题.更改后,我收到了更多警告(所有类型都与以前相同,共 277 个)和更大的 .def 文件(15MB,进度).但是输出 .lib 文件的大小完全相同(1.48MB - 这是非常小的 .lib)并且链接器错误占上风.所以我想 .lib 创建仍然有问题.
.def
文件:http://pastebin.com/E81s6dnh最后几行让我感到不舒服:
256 FF 00001CF0 libvlc_vprinterr257 100 00001790 libvlc_wait链接:致命错误 LNK1328:缺少字符串表
检查屏幕截图中的 dumpbin
命令,
libvlc.dill"应该是libvlc.dll"
一般来说,当链接器的所有输入都正确时&然而,如果链接器抱怨,那么我会专门查看一些 lib import #defines.有时,如果没有在允许导入 lib 的链接器输入设置中定义一些 #DEFINE,就不能只导入 .lib.例如IMPORT_X_LIB.您是否为 vlc lib 定义了任何此类导入库 #define.如果是,您必须在链接器输入中添加它们.
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
edit:
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.
这篇关于带有 C++ 的 VLC Api - .lib 的链接器错误(即使我已将它添加到我的 VC++ 项目中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!