Questions tagged [glib]
GLib is a general-purpose and cross-platform utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on.
glib
1,548
questions
119
votes
5
answers
82k
views
GLib compile error (ffi.h), but libffi is installed
After a succesful configure, make exits with snipped
gclosure.c:29:17: fatal error: ffi.h: No such file or directory
compilation terminated.
I have libffi installed, and locate ffi.h gives:
/home/...
89
votes
5
answers
8k
views
What's the significance of a C function declaration in parentheses apparently forever calling itself?
In gatomic.c of glib there are several function declarations that look like this:
gboolean
(g_atomic_int_compare_and_exchange_full) (gint *atomic,
gint ...
51
votes
6
answers
29k
views
Material to learn GObject and Glib [closed]
I am comfortable with C. but need to learn GObject and Glib for gstreamer. All i found on net is Gobject reference manual. Its good but looking for tutorial for Gobject/Glib as the main focus is on ...
50
votes
17
answers
9k
views
Does using large libraries inherently make slower code?
I have a psychological tic which makes me reluctant to use large libraries (like GLib or Boost) in lower-level languages like C and C++. In my mind, I think:
Well, this library has thousands of
...
50
votes
1
answer
79k
views
glibconfig.h no such file or directory
I just installed glib in Raspbian(Debian version). I want to read a config file using glib. I am trying to write a C application in Codeblocks and I use the header
#include <glib.h>
But I ...
45
votes
5
answers
64k
views
Why can't I build a "hello world" for glib?
So here's the world's simplest glib program:
#include <glib.h>
I try to compile it with gcc test.c and I get:
test.c:1:18: error: glib.h: No such file or directory
So I make sure that I have ...
43
votes
2
answers
22k
views
What exactly are GLib and GObject?
I have been looking into the source code of python-mpdor and it mentions that it is
gobject-based, for easy event handling (in the high-level client
class).
Can someone explain to me in simple ...
41
votes
4
answers
28k
views
Sublime Text on Ubuntu 14.04 - Keeps attempting to remove it
Sublime & from Terminal, opens a Sublime Text window, but keep getting this message:
(sublime: 6476): GLib-CRITICAL **; Source ID 1982 was not found when attempting to remove it.
The Source ID ...
40
votes
2
answers
17k
views
glibc, glib and gnulib
what are differences in the strength and features in gnulib glib and glibc
Thanks!
39
votes
3
answers
16k
views
Installing glib in non-standard prefix fails
I'm trying to install glib in a non-standard prefix but I get the following when running make install:
/bin/sh ../libtool --mode=install /usr/bin/install -c libgthread-2.0.la '/root/build/lib'
...
31
votes
7
answers
22k
views
Why use GLib functions?
While programming in C and GTK+, why is it "better" to use g_strdup_printf, g_free, g_strcmp0 etc... and fellow GLib functions?
29
votes
4
answers
41k
views
Linux glib needs pkg-config and pkg-config needs glib?
I try to install udev. And udev gives me an error during the ./configure
--exists: command not found configure: error:
pkg-config and "glib-2.0 >= 2.16" not found, please set GLIB_CFLAGS and ...
26
votes
2
answers
10k
views
How do I get GDB to break on a GLib assertion failure?
Somewhere in a mass of code that I did not write (but I am trying to debug), an assertion fails in the GLib library:
(process:31987): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != ...
26
votes
1
answer
672
views
Gettext message catalogues from virtual dir within PYZ for GtkBuilder widgets
Is there an established approach to embed gettext locale/xy/LC_MESSAGES/* in a PYZ bundle? Specifically to have Gtks automatic widget translation pick them up from within the ZIP archive.
For other ...
24
votes
2
answers
9k
views
Valgrind reports memory 'possibly lost' when using glib data types
I'm developing a library using a number of glib datastructures (GHashTable, GSList etc.). I've been checking my code frequently for memory leaks using valgrind. Most of the issues valgrind points out ...
21
votes
6
answers
23k
views
What is the recommended way of using GLib2 with CMake
Id like to use GLib in my C application which uses CMake as the build system.
Now, I'm somehow confused how I should enable GLib in my CMakeLists.txt. Basically, you add libraries in cmake using the ...
21
votes
3
answers
26k
views
How Do I Run ./configure with MinGW?
I am looking at this webpage
http://mathieu.carbou.free.fr/wiki/index.php?title=Glib_for_Win32
And it tells me I need to run the following commands.
./configure
make
make install
How do I actually ...
20
votes
5
answers
33k
views
How to compile a basic D-Bus/glib example?
I'm trying to learn how to use D-Bus with C bindings. I've never used D-Bus before. I'm following this tutorial, which I assume is the official one (Freedesktop.org). I've read it until this paragraph ...
20
votes
1
answer
12k
views
GTK: cancel timeout
GTK allows you to set a timeout with g_timeout_add. Just like g_signal_connect, the g_timeout_add function returns an id representing the timeout. So, is there a way to cancel a timeout using the id?...
20
votes
3
answers
7k
views
GLib v APR pros and cons of each [closed]
I have a couple of hobby C programming projects that I would like to start. I am looking for an open source library that has a liberal license (I want credit, but pretty much anybody can use). The ...
20
votes
1
answer
10k
views
Running multiple concurrent GMainLoops
Are users of GLib allowed to run multiple GMainLoop instances concurrently in multiple threads, with each thread running its own instance? I've found "yes" and "no" answers all over the place. I ...
19
votes
2
answers
12k
views
Reassigning Smart Pointers
Generally speaking do smart pointers such as std::unique_ptr and Glib::RefPtr delete their object when reassigned to point at another object, given they are the only pointers holding that given object ...
17
votes
6
answers
15k
views
gobject-2.0-0 not able to load on macbook
I am facing this error when I start my flask application on Python3 and Mac OS:
OSError: cannot load library 'gobject-2.0-0': dlopen(gobject-2.0-0, 2): image not found. Additionally, ctypes.util....
17
votes
2
answers
5k
views
Why is it better to use Glib data types (e.g. `gint` instead of `int`)? [duplicate]
Possible Duplicate:
Why does glib redefine types?
In the GTK+ 2.0 tutorial, I can read here the following statement about data types:
There are a few things you probably noticed in the ...
16
votes
2
answers
28k
views
How to compile & use GLib with MinGW
I want to use the Gnome GLib in a Windows environment using the free MinGW compiler to develop in C. The problem is, I have absolutely no idea how to compile this library. Would any of you please ...
16
votes
1
answer
2k
views
How to upgrade gtk2hsC2hs?
I am trying cabal install glib-0.12.3 under my Ubuntu 11.10 using cabal-install 0.10.2. However, it shows the following error messages:
setup: The program gtk2hsC2hs version >=0.13.5 is required ...
15
votes
1
answer
25k
views
trying to import a module: undefined symbol: PyUnicodeUCS4_DecodeUTF8
import glib fails with:
ImportError: /usr/lib/python2.7/dist-packages/glib/_glib.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
How can I fix this?
Python version is Python 2.7.3rc2. The OS is ...
15
votes
3
answers
12k
views
Installing Sharp /usr/include/vips/vips8:35:25: fatal error: glib-object.h
I am trying to install sharp on Ubuntu 16.04 LTS.
I originally did not have vips, so I installed
sudo apt-get install libvips-dev
That fixed the first error, but now I get another error that I ...
14
votes
5
answers
4k
views
meld - gi._glib.GError: Icon 'meld-change-apply-right' not present in theme. What is wrong with the installation?
I have managed to install the meld 3.14.2 and all the dependency packages, by compiling each package from source and all are installed on a NFS share with --prefix=<base>/meldfor the meld tool &...
14
votes
2
answers
9k
views
Why would anyone use gboolean (GLib) instead of bool type?
I've been reading some code which uses gtk+ and I've encountered types like gboolean and gunichar.
As long as I can understand the point of using gunichar instead of wchar_t (glib gunichar and ...
14
votes
2
answers
2k
views
Why does GLib redefine types?
What is the reasoning behind types to be redefined in GLib? Why do they turn char into gchar, int into gint, etc.?
14
votes
2
answers
55k
views
glib.h: No such file or directory
I tried installing gtk and glib using
sudo apt-get install libglib2.0-dev
and
sudo apt-get install libgtk2.0-dev
but locate glib.h does not return any path for glib
results of locate glib.h are
$ ...
14
votes
1
answer
571
views
Mimicing glib.spawn_async with Popen…
The function glib.spawn_async allows you to hook three callbacks which are called on event on stdout, stderr, and on process completion.
How can I mimic the same functionality with subprocess with ...
13
votes
1
answer
3k
views
GLib's GAsyncQueue vs. POSIX message_queue
Does anyone have any idea of the relative performance of GLib's GAsyncQueue vs. POSIX message_queue for inter-thread communication? I will have many small messages (both one way and request-response ...
13
votes
3
answers
4k
views
When to unref a GVariant that has a floating reference?
https://developer.gnome.org/glib/unstable/glib-GVariant.html#g-variant-ref-sink
I have read the above glib manual which says: "GVariant uses a floating reference count system. All functions with ...
12
votes
1
answer
2k
views
Is GHashTable (glib2) thread safe?
I have multiple threads adding, modifying and looking up data in GHashTable.
Is it threadsafe, or do I need to implement threadsafety myself?
12
votes
1
answer
1k
views
Why does Glibmm/Gtkmm not include the unary dereferencing operator, *, for Glib::RefPtr?
Glib::RefPtr allows dereferencing via '->' but not via '*'. Why is this?
I can of course do:
class Foo {};
Glib::RefPtr<Foo> fooPtr;
fooPtr.operator->();
The docs specifically ...
11
votes
3
answers
12k
views
How can I deactivate 'Warning: Source ID 510 was not found when attempting to remove it - GLib.source_remove(self._idle_event_id)'?
When I execute
#!/usr/bin/env python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.show()
(and more complex examples) I get
/usr/local/lib/python3.4/dist-packages/
matplotlib/...
11
votes
4
answers
8k
views
Vala vapi files documentation
I'd like to hack on an existing GLib based C project using Vala.
Basically what I'm doing is, at the beginning of my build process, using valac to generate .c and .h files from my .vala files and ...
11
votes
1
answer
7k
views
Will strcmp compare utf-8 strings in code point order?
In a C program, I want to sort a list of valid UTF-8-encoded strings in Unicode code point order. No collation, no locale-awareness.
So I need a compare function. It's easy enough to write such a ...
11
votes
1
answer
8k
views
Macro for iterating over a GList
I am using GLib's doubly linked list structure, GList. I would like to know if there is any standard macro for iterating over a GList. I couldn't find any such thing in the GLib documentation. As a ...
10
votes
1
answer
9k
views
How can I set the log level in glib
Is there a way to change the log level in glib so e.g. in a release version of an application the debug messages of g_debug won't be logged to the stdout? Do I really need to implement my own log ...
10
votes
1
answer
1k
views
How portable is GLib?
I know this question might sound strange because GLib is a portability library, but how portable is it? To name one example: Does GLib (including GObject) run on microcontrollers or does it depend on ...
9
votes
3
answers
17k
views
How can I remove the warning in GCC 4.6: "missing initializer [-Wmissing-field-initializers]"?
The code
GValue value = { 0 };
gives the following warning:
missing initializer [-Wmissing-field-initializers]
I know that's a GCC bug, but is there some trick to remove it? It is really not nice ...
9
votes
8
answers
8k
views
compile glib 2.48 does not recognize pcre with utf support
I have compiled pcre 8.38 from source with --enable-utf8 --enable-unicode-properties and a pcretest -C utf retuns 1.
a which pcretest returns /home/mybin/bin/pcretest
However when compiling glib 2....
9
votes
5
answers
1k
views
What non-GUI programs use glib?
What non-GUI programs (daemons) use glib?
9
votes
1
answer
2k
views
How can I find the length of a given GArray?
I have a GArray of GValue (all non-zero) which has been allocated at runtime with g_array_append_val. I wonder how can I find out what's the index of the last element, or more precisely how many ...
9
votes
3
answers
5k
views
glib memory allocation VS std *alloc and free
I tend to use std *alloc/free functions to allocate/free dynamic memory in my C programs.
I wonder if there are any good reasons to use the GLIB Memory Allocation functions instead of the std ones.
...
9
votes
4
answers
7k
views
printing utf8 in glib
Why utf8 symbols cannot be printed via glib functions?
Source code:
#include "glib.h"
#include <stdio.h>
int main() {
g_print("марко\n");
fprintf(stdout, "марко\n");
}
Build it like ...
9
votes
1
answer
3k
views
detect/remove unpaired surrogate character in Python 2 + GTK
In Python 2.7 I can successfully convert the Unicode string "abc\udc34xyz" to UTF-8 (result is "abc\xed\xb0\xb4xyz"). But when I pass the UTF-8 string to eg. pango_parse_markup() or ...