1

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?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.