Cyrus4ever
Cyrus4ever

Reputation: 81

Compiling a gstreamer app using cmake on Windows

I am trying to use the gstreamer library under windows, using cmake.

Here is my simple test code:

#include <gst/gst.h>

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

I got the lib ("gstreamer-1.0-devel-x86-1.6.1.msi") from here: http://gstreamer.freedesktop.org/data/pkg/windows/1.6.1/

and try to compile the program with the following CMakeList.txt:

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})

I would like to avoid using pkgconfig because my goal is to make it easy to compile.

Unfortunately, this does not work:

[ 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 ...

My questions are the following:

Thanks!


Upvotes: 3

Views: 4207

Answers (1)

Cyrus4ever
Cyrus4ever

Reputation: 81

Ok, I found what the problem is. I only need to take *dll.a files, so the code is now:

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

I suppose we can do it in a proper way, so if someone has a better idea, I would be interested.

Upvotes: 2

Related Questions