Search code examples
phpc++php-extensionmpfr

Using a c++ library in my PHP Extension: undefined symbol: mpfr_get_emin_min


Trying to compile my own MPFR Module for PHP, using the mpfr.so library. My extension itself has a simple ping function, which simply returns "pong" to verify, that the extension is actually loaded, and another function, which returns the following:

return ("MPFR library: %-12s\nMPFR header:  %s (based on %d.%d.%d)\n",
            mpfr_get_version(), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
            MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);

This should print the current mpfr lib version. When i compile the php extension, the compiler process has no error. I copy the output so file into the process of PHP modules, and after calling my php script, it actually says undefined symbol: mpfr_get_emin_min

So first i thought, that the library output probably does not know any of the lib mpfr, so i added the compiler flag -lmpfr -lgmp at the very end, but somehow it does nothing.

The file itself simply uses the <mpfr.h>, and i think it is correctly in the extension and available.


Solution

  • Your extension does not know of the function. You have to include the mpfr lib into your extension, so it will be compiled / loaded into it.