[Kernel-meetup] Different behavior of gcc on Ubuntu

Siddhesh Poyarekar sid at reserved-bit.com
Sun Dec 17 03:01:31 PST 2017


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sunday 10 December 2017 07:11 PM, Bhavin Gandhi wrote:
> I was working on a project ecb-des[1] which uses libcrypt. When
> compiled on Ubuntu [gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0] with $ gcc
> -lcrypt ecb-des.c
> 
> it throws the error message[2], but when compiled with $ gcc
> ecb-des.c -lcrypt
> 
> it gets compiled. According to gcc docs[3] (as I have understood
> it) the second way is the correct one. But on other distributions
> both of the ways work, tried on Debian 9 [gcc (Debian 6.3.0-18)
> 6.3.0 20170516] and Fedora 27 [gcc (GCC) 7.2.1 20170915 (Red Hat
> 7.2.1-2)] After searching found no explanation about this different
> in GCC from Ubuntu. The same behavior is there on all the GCC
> versions present in Ubuntu 14.04, 16.04, 17.10. Most of the Ubuntu
> forum posts suggest the same way to link libraries[4] It would be
> great if I get any pointer about this difference, so that I can
> figure out the reason.

Did you compare the binutils versions between the distributions?  That
may give a clue as well.  Link ordering makes a difference, but I
haven't seen such behaviour with source files, only with object files.

Siddhesh
-----BEGIN PGP SIGNATURE-----

iQFJBAEBCAAzFiEEvHxzcmN+wQxX16plecQ9+/HPIYcFAlo2TocVHHNpZEByZXNl
cnZlZC1iaXQuY29tAAoJEHnEPfvxzyGHky4H/1ymFwCNV19QgrgZTEVUQw1VSPY+
SxAdXWFDcr2o/CUuX3r6BdLHjMVXScTBZrU4vM98tzt6+3zha2fJTg28VrPUJ0fl
pcT0BIx6Lfi88HbTMNkNeHhmnO5kyPY4bFiuAply64F6FUgzvCec4j14AE2IHUlS
tUFfCk0ZzG7HGqLEqE6FYGZZpeafsy/ajpVpHJqzgglpu57Xi6Wi7JDp0rIC3usO
0vdHfZvFFPe9vzLbR5wBlo7/AK6qaBFDw2n4UPnZNRqYkA0BTA0X+evbMUS+6bMf
iooicEYyXADFLu1ddFjVHxp/mWPCUBB0FXNKvpO3bXMrM15YGasVgmXHhjI=
=spI5
-----END PGP SIGNATURE-----



More information about the Kernel-meetup mailing list