Re: Bullseye: Linker Can't Find libgps Library
On 2020-07-12 13:16 -0600, Charles Curley wrote:
> I am trying to compile a gpsd client on a i686 bullseye machine. It
> appears the compiler can find the include file for libgps, gps.h.
> However, the linker cannot find the library.
>
> gcc -Wall -ggdb -lm -lgps -o gpsclient gpsclient.c
> gpsclient.c:64:2: warning: #warning Setting up for API version 9.0 [-Wcpp]
> 64 | #warning Setting up for API version 9.0
> | ^~~~~~~
> /usr/bin/ld: /tmp/ccCsxl8F.o: in function `exitHandler':
> /home/charles/versioned/gpsclient/gpsclient.c:130: undefined reference to `gps_stream'
> /usr/bin/ld: /home/charles/versioned/gpsclient/gpsclient.c:131: undefined reference to `gps_close'
> /usr/bin/ld: /tmp/ccCsxl8F.o: in function `showData':
> /home/charles/versioned/gpsclient/gpsclient.c:229: undefined reference to `timespec_to_iso8601'
> /usr/bin/ld: /tmp/ccCsxl8F.o: in function `main':
> /home/charles/versioned/gpsclient/gpsclient.c:474: undefined reference to `gps_open'
> /usr/bin/ld: /home/charles/versioned/gpsclient/gpsclient.c:477: undefined reference to `gps_errstr'
> /usr/bin/ld: /home/charles/versioned/gpsclient/gpsclient.c:503: undefined reference to `gps_stream'
> /usr/bin/ld: /home/charles/versioned/gpsclient/gpsclient.c:506: undefined reference to `gps_waiting'
> /usr/bin/ld: /home/charles/versioned/gpsclient/gpsclient.c:509: undefined reference to `gps_read'
> /usr/bin/ld: /home/charles/versioned/gpsclient/gpsclient.c:515: undefined reference to `gps_stream'
> collect2: error: ld returned 1 exit status
>
> Compilation exited abnormally with code 1 at Sun Jul 12 12:11:46
>
> This compiles and runs on Buster on AMD64 architecture.
I am rather surprised that it does, for I have learned that you always
need to put libraries to link with at the end of the gcc commandline,
i.e.
gcc -Wall -ggdb -o gpsclient gpsclient.c -lm -lgps
should work.
Cheers,
Sven
Reply to: