Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 392439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:09:33+00:00 2026-05-12T16:09:33+00:00

Edit: Revising My Question When building an external PHP module in C, how do

  • 0

Edit: Revising My Question

When building an external PHP module in C, how do I link shared objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:09:33+00:00Added an answer on May 12, 2026 at 4:09 pm

    If your C extension code uses a shared library, you need to declare that in the config.m4 file.

    I strongly recommend using the ext_skel script that’s included in the PHP source to generate a skeleton config.m4:

    ./ext_skel --extname=myextension

    Since you’re linking to a library, by convention you should use the --with-myextension options (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:

      # --with-myextension -> check for lib and symbol presence
      LIBNAME=the_lib_your_extension_needs # you may want to change this
      LIBSYMBOL=some_symbol_in_the_lib_you_extension_needs # you most likely want to change this 
    
      PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
      [
        PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $MYEXTENSION_DIR/lib, MYEXTENSION_SHARED_LIBADD)
        AC_DEFINE(HAVE_MYEXTENSIONLIB,1,[ ])
      ],[
        AC_MSG_ERROR([wrong $LIBNAME lib version or lib not found])
      ],[
        -L$MYEXTENSION_DIR/lib -ldl
      ])
    

    Then to build it, run:

    phpize
    ./configure --with-myextension
    make
    

    Finally you need to copy your module (or ln -s) to wherever your system expects to find it.

    If that all worked then php -m should 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
Edit (updated question) I have a simple C program: // it is not important
EDIT : It turned out that this can only be done through an external
EDIT: Simple version of the question: I want to create server variables in the
Edit: The below question was answered by this . I have a new updated
Edit: I'm looking for solution for this question now also with other programming languages.
EDIT : I've gotten the famous question badge with this question, so I figured
EDIT: I have reworded the title question slightly, and adjusted the text to respond
EDIT: Mangling is fixed - primary issue appears to be the php/mysql connection In
I'm revising for a introduction to programming exam and I have a question which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.