与libvlc链接时,msys2二进制文件缺少libgcc_s_dw2-1.dll

时间:2019-01-16 14:07:57

标签: c++ cmake linker libvlc msys2

我在MSYS2中使用mingw32 / mingw-w64-i686-vlc版本3.0.6-1软件包做了一个最小的示例。该程序仅应通过libvlc库播放单个视频。唯一的问题是,当我尝试运行程序(从MSYS2内部)时,会引发以下错误:

$ ./avtest.exe
C:/Users/michael/Documents/dev/cpp/libvlc-test/avtest.exe: error while loading shared libraries: libgcc_s_dw2-1.dll: cannot open shared object file: No such file or directory

但是它确实存在!

$ ldd avtest.exe
        ntdll.dll => /c/Windows/SysWOW64/ntdll.dll (0x77a20000)
        kernel32.dll => /c/Windows/syswow64/kernel32.dll (0x75780000)
        KERNELBASE.dll => /c/Windows/syswow64/KERNELBASE.dll (0x77420000)
        msvcrt.dll => /c/Windows/syswow64/msvcrt.dll (0x756d0000)
        libwinpthread-1.dll => /mingw32/bin/libwinpthread-1.dll (0x64b40000)
        libvlc.dll => /mingw32/bin/libvlc.dll (0x746c0000)
        libvlccore.dll => /mingw32/bin/libvlccore.dll (0x74130000)
        ADVAPI32.dll => /c/Windows/syswow64/ADVAPI32.dll (0x76800000)
        sechost.dll => /c/Windows/SysWOW64/sechost.dll (0x771b0000)
        RPCRT4.dll => /c/Windows/syswow64/RPCRT4.dll (0x76c80000)
        SspiCli.dll => /c/Windows/syswow64/SspiCli.dll (0x75140000)
        CRYPTBASE.dll => /c/Windows/syswow64/CRYPTBASE.dll (0x75130000)
        IPHLPAPI.DLL => /c/Windows/system32/IPHLPAPI.DLL (0x73990000)
        NSI.dll => /c/Windows/syswow64/NSI.dll (0x767f0000)
        WINNSI.DLL => /c/Windows/system32/WINNSI.DLL (0x73980000)
        SHELL32.dll => /c/Windows/syswow64/SHELL32.dll (0x75b20000)
        SHLWAPI.dll => /c/Windows/syswow64/SHLWAPI.dll (0x75890000)
        GDI32.dll => /c/Windows/syswow64/GDI32.dll (0x76a90000)
        USER32.dll => /c/Windows/syswow64/USER32.dll (0x75980000)
        LPK.dll => /c/Windows/syswow64/LPK.dll (0x76770000)
        USP10.dll => /c/Windows/syswow64/USP10.dll (0x77340000)
        WS2_32.dll => /c/Windows/syswow64/WS2_32.dll (0x75ae0000)
        libgcc_s_dw2-1.dll => /mingw32/bin/libgcc_s_dw2-1.dll (0x6eb40000)
        libiconv-2.dll => /mingw32/bin/libiconv-2.dll (0x66200000)

肯定在那里。

尽管libvlc的链接输出有些奇怪。我不确定这是否重要:

$ ldd /mingw32/bin/libvlc.dll
        ntdll.dll => /c/Windows/SysWOW64/ntdll.dll (0x77a20000)
        kernel32.dll => /c/Windows/syswow64/kernel32.dll (0x75780000)
        KERNELBASE.dll => /c/Windows/syswow64/KERNELBASE.dll (0x77420000)
        ??? => ??? (0x74680000)
        ??? => ??? (0x73ff0000)
        ??? => ??? (0x76800000)
        ??? => ??? (0x756d0000)
        ??? => ??? (0x771b0000)
        ??? => ??? (0x76c80000)
        ??? => ??? (0x75140000)
        ??? => ??? (0x75130000)
        ??? => ??? (0x73990000)
        ??? => ??? (0x767f0000)
        ??? => ??? (0x73980000)
        ??? => ??? (0x64b40000)
        ??? => ??? (0x75b20000)
        ??? => ??? (0x75890000)
        ??? => ??? (0x76a90000)
        ??? => ??? (0x75980000)
        ??? => ??? (0x76770000)
        ??? => ??? (0x77340000)
        ??? => ??? (0x75ae0000)
        ??? => ??? (0x6eb40000)
        ??? => ??? (0x66200000)

如何使它正常运行?

Main.cpp

 #include <stdio.h>
 #include <stdlib.h>
 #include <vlc/vlc.h>

#include <chrono>
#include <thread>

 int main(int argc, char* argv[])
 {
     libvlc_instance_t * inst;
     libvlc_media_player_t *mp;
     libvlc_media_t *m;

     /* Load the VLC engine */
     inst = libvlc_new (0, NULL);

     /* Create a new item */
     //m = libvlc_media_new_location (inst, "http://mycool.movie.com/test.mov");
     m = libvlc_media_new_path (inst, "C:\\Users\\michael\\Desktop\\record-and-send.mp4");

     /* Create a media player playing environement */
     mp = libvlc_media_player_new_from_media (m);

     /* No need to keep the media now */
     libvlc_media_release (m);

 #if 0
     /* This is a non working code that show how to hooks into a window,
      * if we have a window around */
      libvlc_media_player_set_xwindow (mp, xid);
     /* or on windows */
      libvlc_media_player_set_hwnd (mp, hwnd);
     /* or on mac os */
      libvlc_media_player_set_nsobject (mp, view);
  #endif

     /* play the media_player */
     libvlc_media_player_play (mp);

     std::this_thread::sleep_for( std::chrono::seconds( 10 ) ); /* Let it play a bit */

     /* Stop playing */
     libvlc_media_player_stop (mp);

     /* Free the media_player */
     libvlc_media_player_release (mp);

     libvlc_release (inst);

     return 0;
 }

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.11)

# Standardly
set(CMAKE_CXX_STANDARD 11)

# Project name
project(avtest)

SET( CMAKE_CXX_FLAGS_RELEASE  "${CMAKE_CXX_FLAGS_RELEASE} -O2" )
SET( CMAKE_C_FLAGS_RELEASE  "${CMAKE_C_FLAGS_RELEASE} -O2" )

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g -O0")
SET( CMAKE_C_FLAGS_DEBUG  "${CMAKE_C_FLAGS_DEBUG} -Wall -g -O0" )

find_package(Threads)

find_library(VLC_LIB vlc)

add_executable(avtest WIN32 Main.cpp)

target_link_libraries(avtest ${VLC_LIB})

使用

进行编译
$ cmake -G "MinGW Makefiles" . -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DCMAKE_BUILD_TYPE=Debug
$ mingw32-make.exe

也尝试过

  1. 通过pacman -Syu然后通过pacman -Su更新整个msys2系统
  2. 将libgcc_s_dw2-1.dll复制到与可执行文件相同的目录中

0 个答案:

没有答案