This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

[ 中文 ]

gtkmm on Microsoft Windows

Download

There is an Installer available for gtkmm on Microsoft Windows. Since version 2.22 there are also 64 bit versions available.

Installer Descriptions

gtkmm-win32-devel-*.exe contains the dynamic libraries (DLLs) of gtkmm, libxml++, libglademm and all their dependencies, plus header files, import libraries and documentation. You need this to compile applications or libraries that use gtkmm on Windows, with either MinGW or MSVC++.

gtkmm-win64-devel-*.exe contains the same for 64 bit builds with mingw-w64 or MSVC's x64 target platform.

Using the Installers

To use the runtime environment, simply execute the installer and make sure the "Add the gtkmm runtime directory to the PATH variable" option is checked. This is required for Windows to find the gtkmm DLL files. If you know what you do, then you can also uncheck that option. This can be useful if you have multiple versions of gtkmm installed (for example, both runtime and development DLLs) and want to choose which one to use by setting the PATH variable manually. After installing, you are able to run programs using gtkmm.

First, execute the installer. When you intend to use MinGW, then install to a path not containing spaces (so C:\Program Files\Something is a bad idea) since pkg-config has problems with this. See also this mailing list post. To use the development environment, you need to know with which compiler you want to compile your application. MinGW-W64 (note that despite its name the MinGW-W64 project also provides a toolchain to build 32 bit executables) and Visual C++ 2005 (or later) are supported. Older versions of Visual C++ are not supported, and are not likely to work.

The package contains the GTK+ runtime and its dependencies, and also GTK+ header files, import libraries and documentation. You don't need to install anything else to use the package.

All required DLLs are installed into the bin/ subfolder in the installation directory. Additional DLLs are installed into the redist/ subfolder. These are required when redistributing your application, see the section below.

MinGW DLLs

The DLLs prefixed with lib, such as libgtkmm-2.4-1.dll, are required if you build your application with MinGW.

The MinGW DLLs were built with the MinGW-W64 32 Bit or 64 Bit toolchain, respectively. It is not guaranteed that other versions of g++ will work with the built binaries, but they probably do if they are configured to use the same ABI (such as SJLJ stack unwinding). Please let us know if you make positive or negative experiences with these binaries and another version of the GNU compiler.

The DLLs from installer contain debug symbols which might be useful when debugging your application with gdb.

MSVC++ DLLs

The DLLs without a lib prefix, such as gtkmm-vc80-d-2_4.dll are MSVC++ DLLs. The DLL naming convention is module-toolset-(d-)abiversion.dll, where module means the library the DLL contains (such as glibmm, cairomm or gtkmm), toolset means the compiler used to build the DLL (which implies the runtime it is linked against) and abiversion is the ABI version of the library.

Debug DLLs have a d between the toolset and the abiversion. They are required for running the Debug configuration of MSVC++-built applications whereas the DLLs without d are required for the Release configuration.

The MSVC++ DLLs with toolset vc80 (built with MSVC++ 2005) are linked against the runtime DLLs MSVCR80.DLL / MSVCP80.DLL, the ones with vc90 as toolset (built with MSVC++ 2008) are linked against the runtime DLLs MSVCR90.DLL / MSVCP90.DLL and the ones with vc100 as toolset (built with MSVC++ 2010) are linked against the runtime DLLs MSVCR100.DLL / MSVCP100.DLL.

The MSVC++ release DLLs are the same in the runtime and development installers.

GTK+ DLLs

For GTK+ and its dependencies (these are most DLLs that do not end on *mm, except libsigc-2.0.dll and xml++-toolset-2_6.dll) the convention mentioned above is not valid. There is only one DLL for each library, but this one works with both MinGW and MSVC++ (both Debug and Release Target), because they are C libraries, not C++.

Using MinGW

To build your application with MinGW, we recommend that you use the MSYS shell. With MSYS, you can compile your program as on Unix, for example via g++ foo.cc -o foo `pkg-config --cflags --libs gtkmm-2.4`.

You could also use the normal Windows command line to do this, but the backticks syntax would not work, so you would need to run pkg-config separately and insert the correct flags by hand.

The installer only provides native Windows DLLs, not Cygwin DLLs. Instructions on how to build native gtkmm Windows applications using cygwin would be welcome.

Using MSVC++ (Microsoft Visual Studio)

The following are rough instructions on how to setup MSVC++ to build gtkmm applications. There are more detailed instructions on the Using gtkmm with Microsoft Visual Studio page.

To build your application with MSVC++, open the "Property manager" via "View / Property Manager" in the menu, then right click the debug target, select "Add existing property sheet", then navigate to the location to which you installed gtkmm, descend into the MSVC directory and choose the corresponding .vsprops file (or .props for MSVC 2010) for your Visual Studio Version. Users of MSVC++ 2005 should use the gtkmm-vc80-d-2_4.vsprops file, users of MSVC++ 2008 should use the gtkmm-vc90-d-2_4.vsprops file and users of MSVC++ 2010 should use the gtkmm-vc100-d-2_4.vsprops file. Then, do the same for the release target, but choose the version without d in the filename. The gtkmm-2.4.vsprops and gtkmm-2.4d.vsprops should no longer be used. These are the same as the ones for MSVC++ 2005 (the vc80 ones) and are only provided for backwards compatability, so that MSVC can still find them for projects that are still using these.

gtkmm-win32-msvc-propsheet.png

To prevent random crashes with MSVC++ 2005 in the debug version, go to "Project / $MyProject properties" in the menu, make sure the Debug configuration is active (upper left corner of the dialog), then go to "Configuration Properties / C/C++ / Code generation" and choose "Multi-threaded Debug DLL" as Runtime Library. This is because your application needs to be built against the same runtime library as the gtkmm (debug) DLLs.

gtkmm-win32-msvc-codegen.png

You might also want to change "Generate Debug Info" in "Linker / Debugging" to Yes to be able to debug your application. Both options don't seem to be default for the Debug configuration for new, empty projects in MSVC++ 2005. This seems to have been fixed in MSVC++ 2008 and MSVC++ 2010.

gtkmm-win32-msvc-debuginfo.png

To work around a compiler bug in Visual Studio (https://bugzilla.gnome.org/show_bug.cgi?id=158040), the /vd2 flag needs to be passed to the compiler. This is already done automatically for your application if you use the property sheets as mentioned above. However, you need to remember to do this if you don't use the property sheets for some reason.

Updating

When new versions of the installers are released, you can simply execute the new installer to update your gtkmm installation. The installer will detect a previous version of gtkmm and uninstall it first.

Installer Side Effects

Apart from installing files and directories to the hard disk, the installer does the following:

For user-local installation, the registry keys are stored under HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE.

Silent Installs

For silent installations (installation without requiring user intervention, using the /S flag) the following options can be used:

This is mostly mentioned for completeness. When distributing your application, we suggest to redistribute the required gtkmm files with your application instead of running the gtkmm installer because this is less error-prone and more convenient to end users. See the section below for what files you need when redistributing gtkmm with your application.

Redistributing

For your application to work out of the box on other machines that don't have GTK+ or gtkmm installed you need to ship the following files with your application, perhaps using an installer. We suggest that you keep the directory structure of the installed files, so that GTK+ can correctly find its configuration files and modules.

This means that you'll have bin/, etc/, lib/ and share/ folders at the lop level of your package. Since all the DLLs are contained in bin/, this is were your application executable belongs as well. So it might end up in C:\Program Files\YourApplication\bin\YourApplication.exe on the target machine, depending on the installation directory. Most applications using GTK+ on Windows do this, such as GIMP.

When redistributing your application, use the DLLs from the redist/ directory in the gtkmm installation path, not from the bin/ directory. The redist/ ones are stripped, which means debugging symbols have been removed, so that the files are smaller in size. Also, they have been compiled with "-O2", which means they are optimized for speed. The DLLs in bin/ are built with "-O0 -g" which is required for debugging. Debugging optimizated code often confuses gdb. When you use MSVC++ instead of MinGW, then the MSVC++ gtkmm DLLs are in bin/ instead of redist/. This is because it is common to execute both Debug and Release versions from the IDE, so all the DLLs need to be in the PATH.

Please do not install the DLL files into a global system path, such as C:\Windows\System32. Since GTK+ locates files it needs at runtime based on the path where the GTK+ DLL resides, you might also need to install other files, such as modules (image loaders, input modules, etc.) or theme settings into the same path. Also, if two different applications do this, then uninstalling one would need to make sure to keep the files in System32, so the other application does not break. Furthermore, the past has shown that new Glib or GTK+ versions on Windows are not always fully compatible with old ones, even though they try to be. This is improving, however.

gtkmm

You will need all these files for gtkmm:

GTK+ runtime

This is required by gtkmm, so you will need all of these, too. A more detailed explanation of what all these libraries provide is available at the GTK+ for Windows page.

libxml++

If your program uses libxml++ then you will additionally need:

libglademm

If your program uses libglademm, then you will additionally need:

Rebuilding

To rebuild the gtkmm binaries or to recreate the installer, see the Building gtkmm on Windows.


2024-10-23 10:58