No, it isn't just the call to gmpn_set_str that causes the libgmp to be needed. If you just write hello world in C (absolutely no GMP calls at all) and then you compile it with -lgmp and run ldd on the resulting executable, you will see that it needs libgmp.so.*. That is the problem.