Developers‎ > ‎

OBS Compilation


OBS stands for OpenSUSE/Open Build Service and it offers various binaries. The most important part in our aspect is the GTK+ stack for Windows. They're available via the OBS repo.

The problem with these binaires is that they're built differently than the ones found at the official GTK+ site and compiling/linking against them is not as straightforward as it could be. This page intends to give you a few hints regarding this issue.


When you first try to build your GTK+ application using the OBS binaries (after using the official binaries previously), you'll probably get a bunch of syntax errors like these:

include/glib-2.0/glib/gutils.h(146) : error C2143: syntax error : missing '{' before 'const'
include/glib-2.0/glib/gutils.h(310) : error C2054: expected '(' to follow 'inline'
include/glib-2.0/glib/gutils.h(311) : error C2085: 'g_bit_nth_lsf' : not in formal parameter list
include/glib-2.0/glib/gutils.h(312) : error C2082: redefinition of formal parameter 'inline'
include/glib-2.0/glib/gutils.h(312) : error C2146: syntax error : missing ',' before identifier 'gint'
include/glib-2.0/glib/gutils.h(312) : error C2143: syntax error : missing ';' before '('
include/glib-2.0/glib/gutils.h(313) : error C2059: syntax error : ')'
include/glib-2.0/glib/gutils.h(322) : error C2016: C requires that a struct or union has at least one member
include/glib-2.0/glib/gutils.h(322) : error C2061: syntax error : identifier 'GTrashStack'
include/glib-2.0/glib/gutils.h(323) : error C2059: syntax error : '}'

This is due to macros affecting inline support. Fortunately this also happened once with the official binaries, and so a diff made against the previous release revealed the problem. That is, it can be easily fixed with a few lines of change:

--- glibconfig.h.orig   2010-09-27 22:23:56 +0000
+++ glibconfig.h        2010-09-29 01:31:32 +0000
@@ -107,9 +107,13 @@
 #ifdef __cplusplus
 #define        G_HAVE_INLINE   1
 #else  /* !__cplusplus */
+#ifndef _MSC_VER
 #define G_HAVE_INLINE 1
+#endif /* _MSC_VER */
 #define G_HAVE___INLINE 1
+#if !defined(_MSC_VER) && !defined(__DMC__)
 #define G_HAVE___INLINE__ 1
+#endif /* !_MSC_VER and !__DMC__ */
 #endif /* !__cplusplus */
 #ifdef __cplusplus

After this, your application should compile just fine (unless you run into some kind of deprecation introduced over time).


Now you have to link it. You may try to use the .dll.a files, and it will probably link, but when you try to run the application, you get another error, something like:

The procedure entry point gtk_file_selection_get_filename_utf8 could not be located in the dynamic link library libgtk-win32-2.0-0.dll.

The symbol or the filename can be different, it really doesn't matter. The problem is that the libraries are in a format which Visual C++ (MSVC) can't handle properly. You need to convert them with the gendef utility. An example batch script would be:

@echo off
cd lib
for %%A in (..\bin\*.dll) do (
        gendef ..\bin\%%A
        lib /nologo /machine:x86 /def:%%~nA.def

This will generate .def and .lib files for all the DLLs found in the bin folder. Now all you need to do is feed the resulting .lib files into your linker's input.


Terms  |  Report Abuse  |  Powered by Google Sites