Solving undefined symbol: __gmpn_cnd_add_n

After upgrading my server from Debian Wheezy to Jessie, I encountered the following error during apt-get update:

/usr/lib/apt/methods/https: symbol lookup error: /usr/lib/x86_64-linux-gnu/ undefined symbol: __gmpn_cnd_add_n

Debugging this issue is quite simple. We know that the apt software can’t find the function __gmpn_cnd_add_n in the library This kind of errors almost always means that the library where the error occurs ( expects a diffent version of a library it depends on (libgmp). Using ldd we can check which version is actually used:

$ ldd /usr/lib/x86_64-linux-gnu/
[...] => /usr/local/lib/ (0x00007f5ca1b59000)

We can clearly see that from /usr/local/lib is used. This indicates that at some point someone installed a custom version of libgmp on the system that is different to the version installed by the package manager.

Usually we can simply remove /usr/local/lib/ which usually solves the problem because libhogweed starts to use the correct version as installed by the package manager. Beware, however, that other software using libgmp might stop to work because the library version changed. If removing the local library did not work, try re-checking using the method listed above.