gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] ✘gpsd build broken with glibc 2.23


From: Fred Wright
Subject: Re: [gpsd-dev] ✘gpsd build broken with glibc 2.23
Date: Fri, 15 Apr 2016 16:12:58 -0700 (PDT)

On Fri, 15 Apr 2016, Gary E. Miller wrote:

> Dunno why, but i can't compile gpsd any more.  No recent change in the
> area, must be seomthing changed on my dev host?
>
> gcc -o gpsd -pthread gpsd.o timehint.o shmexport.o dbusexport.o -L.
> -lgpsd -lgps_static -lusb-1.0 -lbluetooth -lm -lrt
> -ldbus-1 ./libgpsd.a(serial.o): In function `gpsd_serial_open':
> serial.c:(.text+0xbe5): undefined reference to `major' collect2: error:
> ld returned 1 exit status o
> serial.c last changed in January, and seems unrelated.
>
> I suspect the problem is in serial.c on line 54:
>
>         int devmajor = major(sb.st_rdev);
>
> Not code I am familar with.
>
> major() seems to come from here:
>
> /usr/include/sys/sysmacros.h:#define major(dev) gnu_dev_major (dev)
>
> My sysmacros.h was updated yesterday, when I went to glibc 2.23
> yesterday:
>
> -rw-r--r-- 1 root root 2278 Apr 14 15:23 /usr/include/sys/sysmacros.h
>
> This seems to fix the build:
>
> diff --git a/serial.c b/serial.c
> index d8bdd8c..4144ac5 100644
> --- a/serial.c
> +++ b/serial.c
> @@ -14,6 +14,7 @@
>  #include <unistd.h>
>  #include <sys/socket.h>
>  #include <sys/param.h> /* defines BSD */
> +#include <sys/sysmacros.h>     /* defines major() */
>
>  #include "gpsd_config.h"
>  #ifdef ENABLE_BLUEZ
>
> Ideas anyone?  Doe my patch break any prior versions?

It seems unlikely that a change in a file that wasn't previously included
is responsible for the trouble. :-)

According to the man page, major() is defined by sys/types.h, provided
that _BSD_SOURCE is defined before including it.  I'd stick to the
officially recommended approach unless it doesn't work.  See, e.g.:

        http://linux.die.net/man/3/major

It appears that features.h (included by sys/types.h) defines __USE_BSD if
_BSD_SOURCE is defined, and that that in turn causes sysmacros.h to be
included by sys/types.h.  But one has to be careful to define any feature
test options before *any* includes, not just the one(s) of interest.

Fred Wright



reply via email to

[Prev in Thread] Current Thread [Next in Thread]