exaexa / codecrypt

Post-quantum cryptography tool (THIS REPOSITORY IS ONLY A MIRROR OF THE MAIN ONE, PLEASE DO NOT FILE BUGS HERE)
https://gitea.blesmrt.net/exa/codecrypt
GNU Lesser General Public License v3.0
308 stars 40 forks source link

linkage to the pthread library #9

Closed ghost91- closed 8 years ago

ghost91- commented 8 years ago

When trying to compile codecrypt, i recieved the following errors:

/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/libcryptopp.so: undefined reference to `pthread_key_create'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/libcryptopp.so: undefined reference to `pthread_getspecific'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/libcryptopp.so: undefined reference to `pthread_key_delete'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/libcryptopp.so: undefined reference to `pthread_setspecific'

Simply adding "-lpthread" to the linker flags in "autogen.sh" solves this.

exaexa commented 8 years ago

What environment are you using for compiling? Codecrypt itself doesn't use pthreads, this dependency should get pulled in by -lcryptopp.

Check out if ldd /usr/lib/libcryptopp.so outputs pthread (please paste the output here as well for documentation). If not, putting -lpthread manually to LIBS for your ./configure is a good workaround.

exaexa commented 8 years ago

Relating to the other issue, what output do you get from pkg-config libcrypto++ --libs ?

ghost91- commented 8 years ago

I'm compiling on Arch Linux x86_64. ldd /usr/lib/libcryptopp.so did not output pthread. I compiled the most recent version of crypto++ and ldd did return pthread when in this case, so i suppose this is either a bug of crypto++ or the arch package.

pkg-config libcrypto++ --libs returns -lcryptopp

EDIT: I just compiled version 5.6.2 of crypto++ (the version, which is used for the arch package currently) and it seems it is missing the pthread linkage. 5.6.3 has this issue, too, but it seems to be fixed in the git version of crypto++, so I guess it will be fixed with the next release of crypto++. In the mean time I will ask the package maintainer of the arch package to fix this.

exaexa commented 8 years ago

Anyway, from debian source package:

~/libcrypto++-5.6.1/debian $ grep pthread changelog
  * Link with pthread to avoid warning from dpkg-shlibdeps.
  * Use LDFLAGS=-pthread to fix linking errors.

Debian is explicitly fixing this for the package to avoid dependency breakage. Asking either Crypto++ or Arch packaging folks about the reason for this behavior will probably be the best option to solve this.

PS. crypto++ likes the workaround solution better https://www.cryptopp.com/wiki/Linux#Undefined_Reference_to_pthread :disappointed:

exaexa commented 8 years ago

Shall be resolved by upstream, closing.

If there's some quick&portable fix/workaround for detection whether cryptopp needs -pthread added, please submit a patch.