Question

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 library needs to have strings better than the C standard library and some portable threading primitives.

I am considering GLib and APR. What is your practical experience? Which is the better foundational C library? Are there any other libraries filling the same niche?

Was it helpful?

Solution

I think glib is generally superior to apr. glib has many more datastructures as portable libraries. e.g hash tables, all kind of lists, queues, stacks, dynamic array, also for argument parsing, file io has it's own wrappers also and memory managment is easy modifiable. E.g you can easily make glib use the Boehm Weisser GC this is AFAIKT never been done or easy possible with Apache. I would decide a bit different. If you need a more useful library of data structures glib is a better equipped. If it comes to GUI stuff than libapr has nothing whereas glib has gdk/gtk+ and a lot of stuff for gnome if you like.

However, if it comes to network stuff, libapr definitely has an edge over glib.

So my suggestions is

  • Desktop programming: Use GTK+ and glib.
  • Network stuff: Use apr, but be assured glib does have all this portable stuff also.

OTHER TIPS

I'd go with APR. APR is better at portability Unix/Windows (being a dedicated portability library), GLib has traditionally been more Unix-oriented. APR is a larger library than GLib, with lots of useful stuff in it (hash tables, argument parsing, file I/O stuff, memory management, shared memory routines, signal handling, etc.).

Is there a reason you wouldn't want to use the c++ stl? Even if you are writing "c-style" code without classes, you can use c++ strings and data structure.

There are plenty of valid reasons to stick to C, of course. If that's the case, I would second the recommendation for glib. APR is more of a portability layer than a utility library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top