RE: Gtk+ 3.0 and MS Windows



Just in case someone is following :-)

I was able to successfully build GTK+ 3.0.6 using MS VC++ 2008 Express using underlying OpenSUSE win32 binaries. I had to play around with nm.exe and lib.exe (MS proprietary tool) to generate missing dot def files as a usage of gcc libraries (.dll.a) resulted in a weird behavior (like import of symbols from improper dll as I reported before).

Gtk-demo.exe runs mostly okay though toolbar icons are not redrawn after menu popup and it dumps sometimes warnings. Tool Palette demo is glitchy in sense of icons. Entry, Icon View, Text Widget demos don't show up at all. Pickers demo fails with " GLib-GIO-ERROR **: Settings schema 'org.gtk.Settings.FileChooser' is not installed"

I don't have much spare time, but I'll try to summarize what should be done to utilize cross-compiled binaries (like from OpenSUSE) to build stuff using MS VC++. I guess it would be substantial time saver not to manually build dependencies under MS Windows.

Here is the python script I used to convert libraries from gcc to MSVC format:

-----------------8<------------------------------
import os,re,sys,shutil
from os.path import join, getsize
from subprocess import Popen, PIPE
os.environ['PATH'] = os.environ['PATH'] + ";C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\;C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\\;C:\\MinGW\\bin"
#gendef = "C:\\workspace\\glibmm-2.27.99\\MSVC_Net2008\\gendef\\Win32\\Debug\\gendef.exe"
#    dll = re.sub(".a", "", lib)
#    output = Popen([gendef, d, dll, lib], stdout=PIPE).communicate()[0]

def gen(dll):
    name = re.sub("^lib", "", dll)
    name = re.sub("(?:-\\d).dll", "", name)
#    shutil.copyfile(lib, name + ".lib")
    print("Working on %s\n" % dll)
    output = Popen(["nm", "lib%s.dll.a" % name], stdout=PIPE).communicate()[0]
    d = "%s.def" % name
    with open(d, "wb") as f:
        f.write(b"EXPORTS\n")
        for line in output.split(b"\r\n"):
            if (re.match(b".* T _|.* I __nm", line)): #|.* I __imp
                line = re.sub(b"^.* T _|^.* I __nm__", b"", line) #|^.* I _
                f.write(line + b"\n")
        f.write(str.encode("LIBRARY %s\n" % dll))
    p = Popen(["lib", "/def:%s" % d]) #, shell = True)

root = "C:\\workspace\\gtk\\usr\\i686-w64-mingw32\\sys-root\\mingw"
os.chdir(root + "\\lib")
for root, dirs, files in os.walk(root + "\\bin"):
    for name in files:
        if (re.search(".dll", name)):
            print("Processing: %s\n" % name)
            gen(name)


#gen("libatk-1.0-0.dll")
#  glibmm-2.4.def libglibmm-2.4-1.dll libglibmm-2.4.dll.a
# dumpbin /SYMBOLS /OUT:dumpbin.out libglibmm-2.4.dll.a
-----------------8<------------------------------

Mikhail


-----Original Message-----
From: Mikhail Titov [mailto:mlt gmx us] 
Sent: Sunday, March 27, 2011 7:57 PM
To: 'Mikhail Titov'; 'Maarten Bosmans'; 'Gtk+ list'
Subject: RE: Gtk+ 3.0 and MS Windows

2) It turned out that glibconfig.h from OpenSUSE is not MSVC friendly.
Perhaps it redefines something important. I took that from gnome's ftp win32 binary. From quick look at the diff output, there is not much difference other than MS specifics in #ifdef blocks. Now at least gdk-win32 compiles.

Mikhail


> -----Original Message-----
> From: gtk-list-bounces gnome org [mailto:gtk-list-bounces gnome org] 
> On Behalf Of Mikhail Titov
> Sent: Sunday, March 27, 2011 6:20 PM
> To: 'Maarten Bosmans'; 'Gtk+ list'
> Subject: RE: Gtk+ 3.0 and MS Windows
> 
> Maarten:
> 
> 1)
> I was not exactly mixing different sources of windows binaries. I just 
> tried different approaches on how I can get binary GTKMM 2.99 for MSVC 
> in the fastest way.
> 
> 2)
> I can't build Gtk+ 3.0.6 (& 3.0.5) from the source against OpenSUSE 
> binaries for some reason as I get some weird errors like
> 
> c:\gtkmm3\include\glib-2.0\glib\gutils.h(146) : error C2143: syntax 
> error : missing '{' before 'const'
> 
> I have OpenSUSE binaries in c:\gtkmm3\ . But Gtk+ 3.0.5 builds just 
> fine against binaries from gnome project's ftp if I add libmsvcrt.a 
> from MinGW into gtk-demo project. Also I had to change path to demos 
> in main.c around line 48 as it points to old gtk.
> 
> 3)
> I was able to link and run successfully very simple tests against 
> OpenSUSE binaries for Glib with MS VC++ 2008. Although I had also to 
> link against libmsvcrt.a from MinGW as by default it was linking 
> against another runtime library as was correctly pointed by Fan. 
> Without it, simple IO with g_fopen() and fgets() were failing.
> 
> 4)
> However I completely forgot that OpenSUSE binaries and MSVC++ can work 
> for good old plain C only as C++ name mangling is different between 
> compilers. As a result, to get GTKMM I have to follow instructions 
> http://live.gnome.org/gtkmm/MSWindows/BuildingGtkmm (Now I know why 
> there is a delay in a binary release :-) ). It all was built and 
> linked correctly, however for some reason resulting glibmm dll is 
> broken as it is looking for GModule's export in Glib's dll which is 
> nonsense. So I can't run simple example that calls 
> "Glib::Module::get_supported();" , but plain old C interface to Glib 
> like "g_module_build_path()" works just fine. I don't know what messes 
> up libs. Oh well.. it is outside of the scope of this list :-)
> 
> Mikhail
> 
> -----Original Message-----
> From: Maarten Bosmans [mailto:mkbosmans gmail com]
> Sent: Sunday, March 27, 2011 2:08 PM
> To: Gtk+ list
> Cc: Mikhail Titov
> Subject: Re: Gtk+ 3.0 and MS Windows
> 
> 2011/3/25 Mikhail Titov <mlt gmx us>:
> > Maarten:
> >
> > Thanks again! It worked like magic. I'm not sure if I was supposed 
> > to
> get a bunch of dot cpio files in cache/extracted/ folder. I have 7-zip 
> 9.20. Anyway I selected all of them and did "7-zip -> extract here" 
> from explorer. However when I try to run demo I get the following message.
> 
> That's great. The rpm indeed contain a cpio file, so you have to 
> unpack twice. The script I sent the link to does this for you.
> 
> > -----------------8<------------------
> >
> > C:\...che\extracted\usr\i686-w64-mingw32\sys-root\mingw\bin>gtk3-demo.
> > exe
> > **
> > Gtk:ERROR:gtksettings.c:558:gtk_settings_class_init: assertion failed:
> > (result == PROP_ALTERNATIVE_BUTTON_ORDER)
> >
> > This application has requested the Runtime to terminate it in an
> unusual way.
> > Please contact the application's support team for more information.
> >
> > -----------------8<------------------
> >
> > Is there something missing, or is it a known issue? It doesn't 
> > matter
> if I change gtk-alternative-button-order to 1 or 0 in gtkrc of MS- 
> Windows theme.
> 
> If I understand your other mail correctly, you are combining binaries 
> from OBS and those provided on ftp.gnome.org. I'm not entirely sure, 
> but it could be that gives problems. So try downloading all 
> dependencies from OBS. The script I sent the link to does this for you.
> 
> > Mikhail
> 
> So you also got your own build going, great! You may also want to try 
> downloading -devel packages of the dependencies from the OBS for 
> linking your own build of Gtk+ 3. Not sure that would give better 
> results though.
> 
> Maarten
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]