• Home
Name Date Size #Lines LOC

..--

docs/12-May-2024-31,20828,480

fuzzing/12-May-2024-621453

gio/12-May-2024-363,597240,267

glib/12-May-2024-353,179246,926

glibmemdfx/12-May-2024-278212

gmodule/12-May-2024-2,3581,527

gobject/12-May-2024-53,97333,394

gthread/12-May-2024-12581

m4macros/12-May-2024-1,1131,005

po/12-May-2024-506,698407,941

subprojects/12-May-2024-3528

tests/12-May-2024-23,07918,821

.clang-formatD12-May-2024489 1211

.dir-locals.elD12-May-202441 21

.gitattributesD12-May-2024658 1716

AUTHORSD12-May-20241.3 KiB4136

BUILD.gnD12-May-202418.4 KiB759707

CONTRIBUTING.mdD12-May-202410.6 KiB275204

COPYINGD12-May-202425.9 KiB503418

HACKINGD12-May-2024571 1813

INSTALL.inD12-May-20244.3 KiB12688

NEWSD12-May-2024501.5 KiB13,48011,241

NEWS.pre-1-3D12-May-20248.5 KiB212176

OAT.xmlD12-May-20244.4 KiB7618

READMED12-May-202414 21

README.OpenSourceD12-May-2024483 1110

README.mdD12-May-20241.7 KiB5037

README.rationaleD12-May-2024505 117

README.win32D12-May-202421 21

README.win32.mdD12-May-202410.7 KiB234176

bundle.jsonD12-May-2024942 3131

check-abis.shD12-May-2024799 2418

clang-format-diff.pyD12-May-20245 KiB167137

config.hD12-May-20245.9 KiB426215

glib-gettextize.inD12-May-20245.3 KiB188140

glib.doapD12-May-20242.3 KiB6553

glib.suppD12-May-202417.1 KiB1,1011,002

meson.buildD12-May-202478.1 KiB2,3962,170

meson_options.txtD12-May-20243.6 KiB129105

msvc_recommended_pragmas.hD12-May-20242.1 KiB4029

template-tap.test.inD12-May-202473 54

template.test.inD12-May-202457 43

README

1See README.md
2

README.OpenSource

1[
2    {
3        "Name": "glib",
4        "License": "LGPL V2.1",
5        "License File": "COPYING",
6        "Version Number": "2.68.1",
7        "Upstream URL": "https://www.gtk.org/",
8        "Description": "GLib is the low-level core library that forms the basis for projects such as GTK and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system."
9  }
10]
11

README.md

1# GLib
2
3GLib is the low-level core library that forms the basis for projects such
4as GTK and GNOME. It provides data structure handling for C, portability
5wrappers, and interfaces for such runtime functionality as an event loop,
6threads, dynamic loading, and an object system.
7
8The official download locations are:
9  <https://download.gnome.org/sources/glib>
10
11The official web site is:
12  <https://www.gtk.org/>
13
14## Installation
15
16See the file '[INSTALL.in](INSTALL.in)'
17
18## How to report bugs
19
20Bugs should be reported to the GNOME issue tracking system.
21(<https://gitlab.gnome.org/GNOME/glib/issues/new>). You will need
22to create an account for yourself.
23
24In the bug report please include:
25
26* Information about your system. For instance:
27  * What operating system and version
28  * For Linux, what version of the C library
29  * And anything else you think is relevant.
30* How to reproduce the bug.
31  * If you can reproduce it with one of the test programs that are built
32  in the tests/ subdirectory, that will be most convenient.  Otherwise,
33  please include a short test program that exhibits the behavior.
34  As a last resort, you can also provide a pointer to a larger piece
35  of software that can be downloaded.
36* If the bug was a crash, the exact text that was printed out
37  when the crash occurred.
38* Further information such as stack traces may be useful, but
39  is not necessary.
40
41## Patches
42
43Patches should also be submitted as merge requests to gitlab.gnome.org. If the
44patch fixes an existing issue, please refer to the issue in your commit message
45with the following notation (for issue 123):
46Closes: #123
47
48Otherwise, create a new merge request that introduces the change, filing a
49separate issue is not required.
50

README.rationale

1This file documents various major decisions which affect GLib development,
2giving a brief rationale of each decision, plus a link to further discussion.
3
4
5 * Compiler attributes: https://bugzilla.gnome.org/show_bug.cgi?id=113075#c46
6
7   GLib uses GIR annotations instead of compiler attributes. They are tidier,
8   already supported by GLib and GNOME tools, and accomplish the same task as
9   compiler attributes. GLib does not provide macros for attributes like
10   nonnull because it would not use them.
11

README.win32

1See README.win32.md
2

README.win32.md

1Chun-wei Fan `<fanc999@yahoo.com.tw>`
2Philip Withnall `<withnall@endlessm.com>`
3Nirbheek Chauhan `<nirbheek@centricular.com>`
4
5This document was last updated in 2019. You're reading this in the future, and
6lots of information might be misleading or outdated in your age. You have been
7warned.
8
9# General
10
11For prebuilt binaries (DLLs and EXEs) and developer packages (headers,
12import libraries) of GLib, Pango, GTK+ etc for Windows, go to
13https://www.gtk.org/download/windows.php . They are for "native"
14Windows meaning they use the Win32 API and Microsoft C runtime library
15only. No POSIX (Unix) emulation layer like Cygwin is involved.
16
17To build GLib on Win32, you can use either GCC ("MinGW") or the Microsoft
18Visual Studio toolchain. For the latter, Visual Studio 2015 and later are
19recommended. For older Visual Studio versions, see below.
20
21You can also cross-compile GLib for Windows from Linux using the
22cross-compiling mingw packages for your distro.
23
24Note that to just *use* GLib on Windows, there is no need to build it
25yourself.
26
27On Windows setting up a correct build environment is very similar to typing
28`meson; ninja` like on Linux.
29
30The following preprocessor macros are to be used for conditional
31compilation related to Win32 in GLib-using code:
32
33- `G_OS_WIN32` is defined when compiling for native Win32, without
34  any POSIX emulation, other than to the extent provided by the
35  bundled Microsoft C library.
36
37- `G_WITH_CYGWIN` is defined if compiling for the Cygwin
38  environment. Note that `G_OS_WIN32` is *not* defined in that case, as
39  Cygwin is supposed to behave like Unix. `G_OS_UNIX` *is* defined by a GLib
40  for Cygwin.
41
42- `G_PLATFORM_WIN32` is defined when either `G_OS_WIN32` or `G_WITH_CYGWIN`
43  is defined.
44
45These macros are defined in `glibconfig.h`, and are thus available in
46all source files that include `<glib.h>`.
47
48Additionally, there are the compiler-specific macros:
49- `__GNUC__` is defined when using GCC or Clang
50- `__clang__` is defined when using Clang or Clang-CL
51- `_MSC_VER` is defined when using MSVC or Clang-CL
52
53`G_OS_WIN32` implies using the Microsoft C runtime, which used to be
54`msvcrt.dll` and is now the [Universal CRT](https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2015)
55when building with Visual Studio. When using the MinGW-GCC toolchain, the CRT
56in use depends on the settings used while the toolchain was built. We highly
57recommend [using the Universal CRT when building with
58MinGW](https://mingwpy.github.io/ucrt.html) too.
59
60GLib is not actively tested with the static versions of the UCRT, but if you
61need to use those, patches are welcome.
62
63# Building software that use GLib or GTK+
64
65Building software that just *uses* GLib or GTK+ also require to have
66the right compiler set up the right way. If you intend to use MinGW-GCC,
67follow the relevant instructions below in that case, too.
68
69You should link to GLib using the `-mms-bitfields` GCC flag. This flag means
70that the struct layout rules are identical to those used by MSVC. This is
71essential if the same DLLs are to be usable both from gcc- and MSVC-compiled
72code.
73
74## Cross-CRT issues
75
76You should take care that the DLLs that your code links to are using the same
77C runtime library. Not doing so can and likely will lead to panics and crashes
78**unless** you're very careful while passing objects allocated by a library
79linked with one CRT to a library linked to another CRT, or (more commonly) not
80doing that at all.
81
82If you *do* pass CRT objects across CRT boundaries, do not file any issues
83about whatever happens next.
84
85To give an example, opening a `FILE` handle created by one CRT cannot be
86understood by any other CRT, and will lead to an access violation. You also
87cannot allocate memory in one CRT and free it using another.
88
89There are [many other cases where you must not allow objects to cross CRT boundaries](https://docs.microsoft.com/en-us/cpp/c-runtime-library/potential-errors-passing-crt-objects-across-dll-boundaries?view=vs-2019),
90but in theory if you're **very very** careful, you can make things work. Again,
91please do not come to us for help if you choose to do this.
92
93# Building GLib
94
95You can build GLib with MinGW-GCC, MSVC, or (experimentally) with Clang-CL.
96
97For all compilers, you will need the following:
98
99- Install Python 3.6.x or newer, either 32-bit or 64-bit. We recommend enabling
100  the option to add it to your `PATH`.
101- [Install Meson](https://mesonbuild.com/Getting-meson.html)
102- Install the [Ninja build tool](https://github.com/ninja-build/ninja/releases), which can also be
103  installed with `pip3`. You can skip this step if you want to generate Visual
104  Studio project files.
105- [git for Windows](https://gitforwindows.org/) is required, since Meson makes
106  use of git to download dependencies using subprojects.
107
108## Building with MinGW-GCC
109
110Open your MSYS or [MSYS2](https://www.msys2.org/) shell where you have the
111MinGW-GCC toolchain installed, and build GLib [like any other Meson
112project](https://mesonbuild.com/Quick-guide.html#compiling-a-meson-project).
113
114## Building with Visual Studio 2015 or newer
115
116Meson is now the only supported method of building GLib using Visual Studio.
117
118To do a build using Meson, do the following:
119
120- Open a Visual Studio (or SDK) command prompt that matches the Visual Studio
121  version and build platform (Win32/x86, x64, etc.) that will be used in all
122  the following steps.
123
124- Create an empty directory/folder for the build inside your GLib sources
125  directory, say, `_builddir`, and `cd` into it.
126
127- Set up the build using Meson:
128
129```cmd
130> meson .. --buildtype=<release|debug|debugoptimized> --prefix=<path> [--backend=vs]
131```
132
133 Please see [the Meson docs](https://mesonbuild.com/Builtin-options.html#core-options)
134 for an explanation for `--buildtype`.
135
136 The path passed for `--prefix` need not to be on the same drive as where the
137 build is carried out, but it is recommended to use forward slashes for this
138 path.  The `--backend=vs` option can be used if the Visual Studio project
139 generator is preferred over using Ninja.
140
141- Build, test and install the build:
142  Run `ninja` to build, `meson test` to test and `meson install` to install the
143  build. If you used `--backend=vs`, instead of running `ninja`, you need to
144  use `msbuild` or you can open the generated solution in Visual Studio.
145
146## Building with old versions of Visual Studio
147
148The steps are the same as above, with the following notes about issues that you might face.
149
150### C4819 build errors
151
152If you are building GLib-based libraries or applications, or GLib itself
153and you see a `C4819` error (or warning, before `C4819` is treated as an error
154in `msvc_recommended_pragmas.h`), please be advised that this error/warning should
155not be disregarded, as this likely means portions of the build are not being
156done correctly, as this is an issue of Visual Studio running on CJK (East Asian)
157locales.  This is an issue that also affects builds of other projects, such as
158QT, Firefox, LibreOffice/OpenOffice, Pango and GTK, along with many other projects.
159
160To overcome this problem, please set your system's locale setting for non-Unicode to
161English (United States), reboot, and restart the build, and the code should build
162normally.
163
164### Support for pre-2012 Visual Studio
165
166This release of GLib requires at least the Windows 8.0 SDK in order to be built
167successfully using Visual Studio, which means that building with Visual Studio
1682008 or 2010 is possible only with a special setup and must be done in the
169command line with Ninja.  Please see
170https://devblogs.microsoft.com/cppblog/using-the-windows-software-development-kit-sdk-for-windows-8-consumer-preview-with-visual-studio-2010/
171for references; basically, assuming that your Windows 8.0 SDK is installed in
172`C:\Program Files (x86)\Windows Kits\8.0` (`$(WIN8SDKDIR)` in short), you need
173to ensure the following before invoking Meson to configure the build:
174
175- Your `%INCLUDE%` must not include the Windows 7.0/7.1 SDK include directories,
176  and `$(WIN8SDKDIR)\include\um`, `$(WIN8SDKDIR)\include\um\share` and
177  `$(WIN8SDKDIR)\include\winrt` (in this order) must be before your stock
178  Visual Studio 2008/2010 header directories.  If you have the DirectX SDK installed,
179  you should remove its include directory from your `%INCLUDE%` as well.
180- You must replace the Windows 7.0/7.1 SDK library directory in `%LIB%` with the
181  Windows 8.0 SDK library directory, i.e. `$(WIN8SDKDIR)\lib\win8\um\[x86|x64]`.
182  If you have the DirectX SDK installed, you should remove its library directory
183  from your `%INCLUDE%` as well.
184- You must replace the Windows 7.0/7.1 SDK tools directory from your `%PATH%` with
185  the Windows 8.0 SDK tools directory, i.e. `$(WIN8SDKDIR)\bin\[x86|x64]`.
186  If you have the DirectX SDK installed, you should remove its utility directory
187  from your `%PATH%` as well.
188
189The Windows 8.0 SDK headers may contain an `roapi.h` that cannot be used under plain
190C, so to remedy that, change the following lines (around lines 55-57):
191
192```
193// RegisterActivationFactory/RevokeActivationFactory registration cookie
194typedef struct {} *RO_REGISTRATION_COOKIE;
195// RegisterActivationFactory/DllGetActivationFactory callback
196```
197
198to
199
200```
201// RegisterActivationFactory/RevokeActivationFactory registration cookie
202#ifdef __cplusplus
203typedef struct {} *RO_REGISTRATION_COOKIE;
204#else
205typedef struct _RO_REGISTRATION_COOKIE *RO_REGISTRATION_COOKIE; /* make this header includable in C files */
206#endif
207// RegisterActivationFactory/DllGetActivationFactory callback
208```
209
210This follows what is done in the Windows 8.1 SDK, which contains an `roapi.h`
211that is usable under plain C.  Please note that you might need to copy that file
212into a location that is in your `%INCLUDE%` which precedes the include path for the
213Windows 8.0 SDK headers, if you do not have administrative privileges.
214
215### Visual Studio 2008 hacks
216
217- You need to run the following lines from your build directory, to embed the
218  manifests that are generated during the build, assuming the built binaries
219  are installed to `$(PREFIX)`, after a successful build/installation:
220
221```cmd
222> for /r %f in (*.dll.manifest) do if exist $(PREFIX)\bin\%~nf mt /manifest %f (PREFIX)\bin\%~nf;2
223> for /r %f in (*.exe.manifest) do if exist $(PREFIX)\bin\%~nf mt /manifest %f (PREFIX)\bin\%~nf;1
224```
225
226
227- If building for amd64/x86_64/x64, sometimes the compilation of sources may seem to hang, which
228  is caused by an optimization issue in the 2008 x64 compiler.  You need to use Task Manager to
229  remove all running instances of `cl.exe`, which will cause the build process to terminate.  Update
230  the build flags of the sources that hang on compilation by changing its `"/O2"` flag to `"/O1"`
231  in `build.ninja`, and retry the build, where things should continue to build normally.  At the
232  time of writing, this is needed for compiling `glib/gtestutils.c`, `gio/gsettings.c`,
233  `gio/gsettingsschema.c`, `glib/tests/fileutils.c` and `gio/tests/gsubprocess-testprog.c`
234