title: Compiling a gstreamer app using cmake on Windows
body: <p>I am trying to use the gstreamer library under windows, using cmake.</p>
  
  <p>Here is my simple test code:</p>
  
  <pre><code>#include &lt;gst/gst.h&gt;
  
  int main (void)
  {
      gst_init (NULL, NULL);
      return 0;
  }
  </code></pre>
  
  <p>I got the lib ("gstreamer-1.0-devel-x86-1.6.1.msi") from here: <a href="http://gstreamer.freedesktop.org/data/pkg/windows/1.6.1/" rel="nofollow">http://gstreamer.freedesktop.org/data/pkg/windows/1.6.1/</a></p>
  
  <p>and try to compile the program with the following CMakeList.txt:</p>
  
  <pre><code>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})
  </code></pre>
  
  <p>I would like to avoid using pkgconfig because my goal is to make it easy to compile.</p>
  
  <p>Unfortunately, this does not work:</p>
  
  <pre><code>[ 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 ...
  </code></pre>
  
  <p>My questions are the following:</p>
  
  <ul>
  <li><p>Should I use both .lib and .a files?</p></li>
  <li><p>Why it does not compile? The file libglib-2.0.dll.a is in the lib directory, so I am not sure to understand what the issue is during the linkage...</p></li>
  </ul>
  
  <p>Thanks!</p>
  
  <hr>