首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Windows上使用cmake编译gstreamer应用程序

在Windows上使用cmake编译gstreamer应用程序
EN

Stack Overflow用户
提问于 2015-12-16 17:59:39
回答 1查看 3K关注 0票数 2

我正在尝试使用windows下的gstreamer库,使用cmake。

下面是我的简单测试代码:

代码语言:javascript
运行
复制
#include <gst/gst.h>

int main (void)
{
    gst_init (NULL, NULL);
    return 0;
}

我从这里得到了库("gstreamer-1.0-devel-x86-1.6.1.msi"):http://gstreamer.freedesktop.org/data/pkg/windows/1.6.1/

并尝试使用以下CMakeList.txt编译程序:

代码语言:javascript
运行
复制
cmake_minimum_required(VERSION 2.8.12)

project(test_g)

SET(CMAKE_CXX_WARNING_LEVEL 4)
if (MSVC)
        add_definitions("/W4")
else()
        add_definitions("-Wall -Wextra")
endif ()

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

file(
        GLOB_RECURSE
        source_files
        ./*
)

file(
        GLOB_RECURSE
        gst_files
        ${CMAKE_CURRENT_SOURCE_DIR}/deps/lib/*.a
        ${CMAKE_CURRENT_SOURCE_DIR}/deps/lib/*.lib
)

add_executable(
        test_g
        ${source_files}
)

  set(GSTREAMER_INCLUDE_DIRS "./deps/include/gstreamer-1.0" "./deps/include/glib-2.0" "./deps/lib/glib-2.0/include" "./deps/lib/gstreamer-1.0/include")
  if (WIN32)
   set(GSTREAMER_LIBRARIES ${gst_files})
  else()
    message(FATAL_ERROR "Gstreamer not found")
  endif()

include_directories(${GSTREAMER_INCLUDE_DIRS})
target_link_libraries (test_g ${GSTREAMER_LIBRARIES})

我想避免使用pkgconfig,因为我的目标是使编译变得容易。

不幸的是,这是行不通的:

代码语言:javascript
运行
复制
[ 33%] Linking CXX executable test_g.exe

C:/Users/toto/Documents/GitHub/test_gst/deps/lib/libgstreamer-1.0.a(libgstreamer_1.0_la-gst.o): In function `init_post':
C:\MinGW\msys\1.0\home\Jan\cerbero\sources\windows_x86\gstreamer-1.0-1.6\gst/gst.c:719: undefined reference to `_imp__glib_micro_version'
C:\MinGW\msys\1.0\home\Jan\cerbero\sources\windows_x86\gstreamer-1.0-1.6\gst/gst.c:719: undefined reference to `_imp__glib_minor_version'
C:\MinGW\msys\1.0\home\Jan\cerbero\sources\windows_x86\gstreamer-1.0-1.6\gst/gst.c:719: undefined reference to `_imp__glib_major_version'
C:/Users/toto/Documents/GitHub/test_gst/deps/lib/libgstreamer-1.0.a(libgstreamer_1.0_la-gstinfo.o): In function `parse_debug_level':
C:\MinGW\msys\1.0\home\Jan\cerbero\sources\windows_x86\gstreamer-1.0-1.6\gst/gstinfo.c:1771: undefined reference to `_imp__g_ascii_table'
C:/Users/toto/Documents/GitHub/test_gst/deps/lib/libgstreamer-1.0.a(libgstreamer_1.0_la-gstinfo.o): In function `gst_path_basename':
C:\MinGW\msys\1.0\home\Jan\cerbero\sources\windows_x86\gstreamer-1.0-1.6\gst/gstinfo.c:467: undefined reference to `_imp__g_ascii_table'
C:/Users/toto/Documents/GitHub/test_gst/deps/lib/libgstreamer-1.0.a(libgstreamer_1.0_la-gstinfo.o): In function `gst_info_dump_mem_line':
C:\MinGW\msys\1.0\home\Jan\cerbero\sources\windows_x86\gstreamer-1.0-1.6\gst/gstinfo.c:1931: undefined reference to `_imp__g_ascii_table'
C:/Users/toto/Documents/GitHub/test_gst/deps/lib/libgstreamer-1.0.a(libgstreamer_1.0_la-gststructure.o): In function `gst_structure_parse_simple_string':
C:\MinGW\msys\1.0\home\Jan\cerbero\sources\windows_x86\gstreamer-1.0-1.6\gst/gststructure.c:2221: undefined reference to `_imp__g_ascii_table'
C:/Users/toto/Documents/GitHub/test_gst/deps/lib/libgstreamer-1.0.a(libgstreamer_1.0_la-gststructure.o): In function `gst_structure_validate_name':
... Many other errors ...

我的问题如下:

  • 我应该同时使用.lib和.a文件吗?
  • 为什么它不编译?文件libglib-2.0.dll.a位于lib目录中,所以我不确定在链接过程中问题是什么.

谢谢!

EN

Stack Overflow用户

发布于 2015-12-18 08:57:31

好吧,我找到问题所在了。我只需要接受*dll.a文件,所以现在的代码是:

代码语言:javascript
运行
复制
file(
        GLOB_RECURSE
        gst_files
        ${CMAKE_CURRENT_SOURCE_DIR}/deps/lib/*dll.a
)

我想我们可以用适当的方法来做,所以如果有人有更好的主意,我会感兴趣的。

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34318978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档