简体   繁体   中英

PHP Warning: PHP Startup: Unable to load dynamic library './lib.so' - ./lib.so: undefined symbol: * in Unknown on line 0

I have written and compiled php extension, but when i try to run php i get this error PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/mylib.so' - /usr/lib/php5/20100525+lfs/mylib.so: undefined symbol: _ZNK4Data10strtolowerEPKc in Unknown on line 0 data.h

class Data
{

public:
     // ...
     char *strtolower  ( const char * const ) const;
};

data.cpp

inline char *Data::strtolower(const char *const str) const
{
   char c, *b = estrdup(str), *s = b;
   while(*s != '\0' && (c = *s))
   {
      *s++ = (c >= 0x41 && c <= 0x5a) ? c + 0x20 : c;
   }
   return b;
}

What is this error and why the code compiled? And the main question is how to fix it?

I wrote two answers that may help you on this:

Linux C++ LD_LIBRARY_PATH suppressing standard libraries

How to call function from .so file using php script?

Specifically, I think your error is that your module is not in the ldcache (see the first answer).

Also, you can't inline in the cpp file. Inlining is for header only. Remove the inline and it may work if your module is in the ldcache or LD_LIBRARY_PATH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM