glib

How to compile a basic D-Bus/glib example?

落花浮王杯 提交于 2019-12-03 11:33:14
问题 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 that gives a first sample program , but unfortunately I don't see any indication on this page about how to compile it or which libraries to include. Did I miss something ? My OS is Ubuntu 10.04 32bit. I installed the libdbus-glib-1-dev package. I tried to add #include <dbus/dbus.h> at the

Running multiple concurrent GMainLoops

前提是你 提交于 2019-12-03 09:08:40
问题 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 realize that this question has been asked before in this very forum (December 2011). However, I am able to run two GMainLoop instances at the same time without apparent issue. My test code is very simple: Create a GMainLoop in main() Create a timeout source for the default context and the main loop

GLIB: g_atomic_int_get becomes NO-OP?

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In a larger piece of code, I noticed that the g_atomic_* functions in glib were not doing what I expected, so I wrote this simple example: #include <stdlib.h> #include "glib.h" #include "pthread.h" #include "stdio.h" void *set_foo(void *ptr) { g_atomic_int_set(((int*)ptr), 42); return NULL; } int main(void) { int foo = 0; pthread_t other; if (pthread_create(&other, NULL, set_foo, &foo)== 0) { pthread_join(other, NULL); printf("Got %d\n", g_atomic_int_get(&foo)); } else { printf("Thread did not run\n"); exit(1); } } When I compile this with

How do I get GDB to break on a GLib assertion failure?

别来无恙 提交于 2019-12-03 06:47:50
问题 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 != NULL' failed However, GDB and the code keeps on going. I would like GDB to break where this assertion fails so that I can find out why it is failing. I am not given any more information about where this assertion is. Is there a way to get GDB to break on such a failure? 回答1: Break on g_log() . This

GLib compile error (ffi.h), but libffi is installed

怎甘沉沦 提交于 2019-12-03 06:26:00
问题 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/luca/gcc4.6/gcc-4.6.0/libffi/include/ffi.h.in /usr/include/x86_64-linux-gnu/ffi.h /usr/share/doc/ghc-doc/html/users_guide/ffi.html /usr/share/doc/libffi5/html/Using-libffi.html 回答1: If you have a Debian-based Linux OS with apt-get : sudo apt-get install libffi-dev With a Redhat-base OS: yum install

glibconfig.h no such file or directory

寵の児 提交于 2019-12-03 06:20:48
问题 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 have an error in gtypes.h fatal error:glibconfig.h No such file or directory I used this path project->Build Options->Compiler Settings->Other Options and I added -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include as I read in this tutorial. I have to declare also -L/usr/lib -lm -lglib-2.0 as the tutorial

Why use GLib functions?

社会主义新天地 提交于 2019-12-03 05:36:07
问题 While programming in C and GTK+, why is it "better" to use g_strdup_printf , g_free , g_strcmp0 etc... and fellow GLib functions? 回答1: In general, GLib's purpose is a utility and portability library. Those in itself are reasons to consider using it. The specific functions you mention all offer something extra on top of their C standard library variants: g_strdup_printf is like sprintf , but actually allocates the buffer for you and saves you the guesswork of how large the buffer should be.

Does using large libraries inherently make slower code?

无人久伴 提交于 2019-12-03 05:13:56
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 man hours put into it, and it's been created by people who know a lot more about the language than I ever will. Their authors and fans say that the libraries are fast and reliable, and the functionality looks really useful, and it will certainly stop me from (badly) reinventing wheels. But damn it, I'm never going to use every function in that library. It's too big and it's probably become bloated over

Sublime Text on Ubuntu 14.04 - Keeps attempting to remove it

白昼怎懂夜的黑 提交于 2019-12-03 03:30:52
问题 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 keeps changing. Using Ubuntu 14.04. Any ideas what could be going on? Thanks! 回答1: This page in Ubuntu's bug tracker describes this particular situation. Apparently this is a known bug with 14.04, possibly because of a regression with GLib, or a mismatch between GLib and GTK (so says one of the

How to compile a basic D-Bus/glib example?

纵然是瞬间 提交于 2019-12-03 02:57:09
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 that gives a first sample program , but unfortunately I don't see any indication on this page about how to compile it or which libraries to include. Did I miss something ? My OS is Ubuntu 10.04 32bit. I installed the libdbus-glib-1-dev package. I tried to add #include <dbus/dbus.h> at the beginning of the source file, and to compile with $ gcc -ldbus-1 -I/usr/include/dbus-1.0/ -I/usr/lib/i386