Edit: Revising My Question
When building an external PHP module in C, how do I link shared objects?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your C extension code uses a shared library, you need to declare that in the
config.m4file.I strongly recommend using the
ext_skelscript that’s included in the PHP source to generate a skeleton config.m4:./ext_skel --extname=myextensionSince you’re linking to a library, by convention you should use the
--with-myextensionoptions (as opposed to--enable-myextension). Uncomment the relevant lines in the config.m4 and fill in the details of your lib.Something like the following:
Then to build it, run:
Finally you need to copy your module (or
ln -s) to wherever your system expects to find it.If that all worked then
php -mshould include your module in the list.Unfortunately I’ve never found a good online reference to PHP’s config.m4 commands – the books for this are Sara Golemon’s Extending and Embedding PHP and also parts of George Schlossnagle’s Advanced PHP Programming.
There’s a reasonable beginners guide to creating PHP extensions by Sara Goleman here, but for the meat you really need her book.