Re: Bullseye: Linker Can't Find libgps Library

2020-07-13 Thread Charles Curley
On Mon, 13 Jul 2020 20:28:59 +0200
Sven Joachim  wrote:

> Not really, the reason is that in Bullseye gcc now passes the
> --as-needed option to the linker to reduce unnecessary linking of
> libraries (and dependencies in the Debian package system).

Nice. Thanks for the clarification.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/



Re: Bullseye: Linker Can't Find libgps Library

2020-07-13 Thread Sven Joachim
On 2020-07-12 15:44 -0600, Charles Curley wrote:

> On Sun, 12 Jul 2020 22:04:54 +0200
> Sven Joachim  wrote:
>
>> 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.
>
> Bingo.
>
> charles@white:~/versioned/gpsclient$ gcc -Wall -o gpsclient gpsclient.c -lm 
> -lgps
> gpsclient.c:72:2: warning: #warning Setting up for API version 9.0 [-Wcpp]
>72 | #warning Setting up for API version 9.0
>   |  ^~~
> charles@white:~/versioned/gpsclient$
>
> Worked correctly. Thank you. Interesting.
>
> This is a change from Buster, gcc (Debian 9.3.0-14) 9.3.0 versus gcc
> (Debian 8.3.0-6) 8.3.0. I conjecture the reason is so that gcc can
> accommodate multiple source files on one line, each with their own
> libraries. Something like:
>
> gcc -Wall -o snark foo.c -la -lb -lc bar.c -lb -lc -ld

Not really, the reason is that in Bullseye gcc now passes the
--as-needed option to the linker to reduce unnecessary linking of
libraries (and dependencies in the Debian package system).  According to
the binutils documentation,

,
| '--as-needed' causes a DT_NEEDED tag to only be emitted for a library
| that _at that point in the link_ satisfies a non-weak undefined symbol
| reference from a regular object file or, if the library is not found in
| the DT_NEEDED lists of other needed libraries, a non-weak undefined
| symbol reference from another needed dynamic library.  Object files or
| libraries appearing on the command line _after_ the library in question
| do not affect whether the library is seen as needed.
`

HTH,
Sven



Re: Bullseye: Linker Can't Find libgps Library

2020-07-12 Thread Charles Curley
On Sun, 12 Jul 2020 22:04:54 +0200
Sven Joachim  wrote:

> 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.

Bingo. 

charles@white:~/versioned/gpsclient$ gcc -Wall -o gpsclient gpsclient.c -lm 
-lgps
gpsclient.c:72:2: warning: #warning Setting up for API version 9.0 [-Wcpp]
   72 | #warning Setting up for API version 9.0
  |  ^~~
charles@white:~/versioned/gpsclient$ 

Worked correctly. Thank you. Interesting.

This is a change from Buster, gcc (Debian 9.3.0-14) 9.3.0 versus gcc
(Debian 8.3.0-6) 8.3.0. I conjecture the reason is so that gcc can
accommodate multiple source files on one line, each with their own
libraries. Something like:

gcc -Wall -o snark foo.c -la -lb -lc bar.c -lb -lc -ld

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/



Re: Bullseye: Linker Can't Find libgps Library

2020-07-12 Thread Sven Joachim
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



Bullseye: Linker Can't Find libgps Library

2020-07-12 Thread Charles Curley
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 have run ldconfig manually.

root@white:/usr/lib/i386-linux-gnu# ldconfig -v | fgrep gps
ldconfig: Can't stat /usr/local/lib/i386-linux-gnu: No such file or directory
ldconfig: Can't stat /usr/local/lib/i686-linux-gnu: No such file or directory
ldconfig: Can't stat /lib/i686-linux-gnu: No such file or directory
ldconfig: Can't stat /usr/lib/i686-linux-gnu: No such file or directory
ldconfig: Path `/lib/i386-linux-gnu' given more than once
ldconfig: Path `/usr/lib/i386-linux-gnu' given more than once
ldconfig: /lib/i386-linux-gnu/ld-2.30.so is the dynamic linker, ignoring

libgps.so.26 -> libgps.so.26.0.0
root@white:/usr/lib/i386-linux-gnu# uname -a
Linux white 5.7.0-1-686 #1 SMP Debian 5.7.6-1 (2020-06-24) i586 GNU/Linux
root@white:/usr/lib/i386-linux-gnu#

This also works on buster AMD64 when I have gpsd version 3.20.12 loaded
from buster backports. This is the same version that is in bullseye.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/