On Sat, Feb 07, 2015 at 02:51:53AM +0000, Margaret Lewicka wrote:
On 6 February 2015 at 10:03, Richard W.M. Jones <rjones@redhat.com> wrote: [...]
Linux doesn't have getprogname. One way around this is to add getprogname to the list of functions in configure.ac AC_CHECK_FUNCS. That will cause a macro to be defined which you can use like this:
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1 # define program_name program_invocation_short_name #elif HAVE_GETPROGNAME # define program_name getprogname() #else # define program_name "libguestfs" #endif
Unfortunately that still doesn't help the issue with gnulib, since it expects char *program_name to be set on non-Linux platforms.
I believe I understand the problem now. The gnulib 'error' module uses program_name. As you say above on some platforms -- but not Linux / glibc -- it references it as: extern char *program_name; This means when you compile libguestfs on non-glibc (eg. Mac OS X) gnulib requires program_name as an external reference, which we don't provide. Complicating this is that libguestfs defines a macro called program_name, which prevents us from easily defining the required external symbol. Anyway, I have changed libguestfs to use the macro guestfs___program_name which cannot conflict with anything: https://github.com/libguestfs/libguestfs/commit/5cafedaa45d5993c54bf18274261... I'm not quite sure who/what gnulib is expecting to define program_name. While it would be possible to add the following to libguestfs somewhere (in a .c file): #if /*compiling for Mac OS X*/ char *program_name = "libguestfs"; #endif that could be a mistake if either Darwin itself or the main program (not a library like libguestfs) is expected to define this symbol. So over to you to experiment! Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top