gtk arch issues

Johnson Jones via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 31 16:37:36 PDT 2017


On Monday, 31 July 2017 at 20:37:11 UTC, Mike Wey wrote:
> On 31-07-17 19:16, Johnson Jones wrote:
>> how does one allow both gtk x86 and x64 to work side by side 
>> seamlessly?
>> 
>> I installed x64 first and it seems, because whatever is using 
>> the path to find the gtk runtime, it looks for that first even 
>> in x86 build.
>> 
>> Seems like gtkd's dll resolution is not very intelligent. 
>> While I could manually modify the path each time I switch 
>> archs, that seems pointless.
>> 
>> One of the problems in gtkd is that it has multiple places 
>> where it defines libgdk-3-0.dll.
>> 
>> 
>> I've tried modifying gdkD so that it uses versioning properly 
>> by searching for libgdk-3-0.dll and changing all to use an x86 
>> or x64 when appropriate but that doesn't seem to help. 
>> Probably have to rebuild gtkD.
>> 
>> Anyways, doesn't seem to be a great solution ;/ Any ideas and 
>> maybe someone can add an issue to the github page to get this 
>> fixed? (I can't do it for a while because of other issues).
>> 
>
> At startup GtkD searches the Path for "libgtk-3-0.dll", when it 
> finds one it checks the architecture of the library. If it's 
> the correct architecture it calls `SetDllDirectory` so that the 
> directory with the correct architecture will be searched first 
> by `LoadLibrary`.
>
> If it's not the correct architecture it continues searching, if 
> no library with the correct architecture is found, we rely on 
> `LoadLibrary` to error out if the libraries are also not in the 
> other locations searched by `LoadLibrary`.

This is not true(at least completely). I have have a fresh 
windows 10 install with fresh dmd and gtkd and gtk x64 and 
x86(installed later).

When running my app in x64 mode it tried to use the x64 but the 
app crashed and I didn't know why as no error message and bug in 
visual D wouldn't allow me to use BP's to find out how far the 
app was getting.

So I decided to install the x86 version. Ran the project in x86 
mode but gtkd was trying to load the x64 dlls and told me they 
were wrong. Remember, now I have both versions on my system. I 
decided to modify gtkd and using some versioning, in which case 
this got me to allow x86 to work as it now used *x86.dll's. I 
noticed that gtksharp was installed in program files (x86).

I then tried to build the x64 version and the app just loads then 
quits but the debug console shows what I pasted and shows that it 
is trying to load stuff from gtksharp.

All I installed as gtk3-runtime_3.22.4_64-bit and 
gtk3-runtime_3.22.4_32-bit.

Now, it may turn out that gtksharp was installed by something 
else(visual studio? or maybe a few other apps I installed). That 
seems to be the case as the modified date predates install of 
gtk3 and seems to correlate to when I installed visual studio 
2017 with it's 50+ gigs worth of crap.

Why is my x64 app trying to load those files though and specially 
from the wrong version? the x86 version


The files being loaded(I suppose they are, not sure what the 
unloaded means):

C:\Windows\SysWOW64\kernel32.dll unloaded.
C:\Windows\SysWOW64\winmmbase.dll unloaded.
C:\Windows\SysWOW64\winmmbase.dll unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\libgdk_pixbuf-2.0-0.dll 
unloaded.
C:\Windows\SysWOW64\dnsapi.dll unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\libpangoft2-1.0-0.dll 
unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\libgdk-3-0.dll unloaded.
C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.15063.483_none_6dad63fefc436da8\comctl32.dll unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\librsvg-2-2.dll unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\libcroco-0.6-3.dll 
unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\libxml2-2.dll unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\libxml2-2.dll unloaded.
C:\Windows\SysWOW64\winhttp.dll unloaded.
C:\Windows\SysWOW64\OnDemandConnRouteHelper.dll unloaded.


for x86, for x64 I get

C:\Program Files (x86)\Gtk-Runtime\bin\libepoxy-0.dll unloaded.
C:\Program Files (x86)\GtkSharp\2.12\bin\libgdk_pixbuf-2.0-0.dll 
unloaded.
C:\Program Files (x86)\Gtk-Runtime\bin\libgdk_pixbuf-2.0-0.dll 
unloaded.
C:\Windows\System32\dwmapi.dll unloaded.
C:\Windows\System32\ole32.dll unloaded.
C:\Windows\System32\setupapi.dll unloaded.
C:\Windows\System32\winmm.dll unloaded.
C:\Program Files\Gtk-Runtime\bin\libcairo-gobject-2.dll unloaded.
C:\Program Files\Gtk-Runtime\bin\libcairo-2.dll unloaded.
C:\Program Files\Gtk-Runtime\bin\libgdk-3-0x64.dll unloaded.
The program '[3420] test.exe' has exited with code 1 (0x1).


as you can see, some files are loaded that are from x86. 
Remember, I modified gtk so that it duplicates all the dll's with 
the x??.dll's and modified gtkd to take those x??.dll's instead, 
which you can see in the last libgdk-3-0x64.

So, those files being loaded are surely not coming from inside 
gtkd?

I modified things like

version (Windows)
{
	version(X86)
	{
		const string[LIBRARY.max+1] importLibs =
		[
			LIBRARY.ATK:           "libatk-1.0-0x86.dll",
			LIBRARY.CAIRO:         "libcairo-2x86.dll",
			LIBRARY.GDK:           "libgdk-3-0x86.dll",
			LIBRARY.GDKPIXBUF:     "libgdk_pixbuf-2.0-0x86.dll",
			LIBRARY.GLIB:          "libglib-2.0-0x86.dll",
			LIBRARY.GMODULE:       "libgmodule-2.0-0x86.dll",
			LIBRARY.GOBJECT:       "libgobject-2.0-0x86.dll",
			LIBRARY.GIO:           "libgio-2.0-0x86.dll",
			LIBRARY.GTHREAD:       "libgthread-2.0-0x86.dll",
			LIBRARY.GTK:           "libgtk-3-0x86.dll",
			LIBRARY.PANGO:         "libpango-1.0-0x86.dll",
			LIBRARY.PANGOCAIRO:    "libpangocairo-1.0-0x86.dll",
			LIBRARY.GLGDK:         "libgdkglext-3.0-0x86.dll",
			LIBRARY.GLGTK:         "libgtkglext-3.0-0x86.dll",
			LIBRARY.GDA:           "libgda-4.0-4x86.dll",
			LIBRARY.GSV:           "libgtksourceview-3.0-0x86.dll",
			LIBRARY.GSV1:          "libgtksourceview-3.0-1x86.dll",
			LIBRARY.GSTREAMER:     "libgstreamer-1.0x86.dll",
			LIBRARY.GSTINTERFACES: "libgstvideo-1.0x86.dll",
			LIBRARY.VTE:           "libvte-2.91x86.dll",
			LIBRARY.PEAS:          "libpeas-1.0x86.dll",
			LIBRARY.RSVG:          "librsvg-2-2x86.dll",
		];
	} else
	{
		const string[LIBRARY.max+1] importLibs =
		[
			LIBRARY.ATK:           "libatk-1.0-0x64.dll",
			LIBRARY.CAIRO:         "libcairo-2x64.dll",
			LIBRARY.GDK:           "libgdk-3-0x64.dll",
			LIBRARY.GDKPIXBUF:     "libgdk_pixbuf-2.0-0x64.dll",
			LIBRARY.GLIB:          "libglib-2.0-0x64.dll",
			LIBRARY.GMODULE:       "libgmodule-2.0-0x64.dll",
			LIBRARY.GOBJECT:       "libgobject-2.0-0x64.dll",
			LIBRARY.GIO:           "libgio-2.0-0x64.dll",
			LIBRARY.GTHREAD:       "libgthread-2.0-0x64.dll",
			LIBRARY.GTK:           "libgtk-3-0x64.dll",
			LIBRARY.PANGO:         "libpango-1.0-0x64.dll",
			LIBRARY.PANGOCAIRO:    "libpangocairo-1.0-0x64.dll",
			LIBRARY.GLGDK:         "libgdkglext-3.0-0x64.dll",
			LIBRARY.GLGTK:         "libgtkglext-3.0-0x64.dll",
			LIBRARY.GDA:           "libgda-4.0-4x64.dll",
			LIBRARY.GSV:           "libgtksourceview-3.0-0x64.dll",
			LIBRARY.GSV1:          "libgtksourceview-3.0-1x64.dll",
			LIBRARY.GSTREAMER:     "libgstreamer-1.0x64.dll",
			LIBRARY.GSTINTERFACES: "libgstvideo-1.0x64.dll",
			LIBRARY.VTE:           "libvte-2.91x64.dll",
			LIBRARY.PEAS:          "libpeas-1.0x64.dll",
			LIBRARY.RSVG:          "librsvg-2-2x64.dll",
		];
	}
}


and

version (Windows)
{
	version(X86)
		static immutable LIBRARY_GDKPIXBUF = 
["libgdk_pixbuf-2.0-0x86.dll"];
	else
		static immutable LIBRARY_GDKPIXBUF = 
["libgdk_pixbuf-2.0-0x64.dll"];
}


So, the question is, is this a gtkd problem or a gtk problem? In 
either case, what's the way to get them both to work. Do you guys 
actually test out both versions installed on the same system?



More information about the Digitalmars-d-learn mailing list