PHP and SWIG

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #1

    PHP and SWIG

    Hi..
    I am trying to call a c function from a PHP.
    But i am getting following error.

    Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/example.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/example.so: cannot open shared object file: No such file or directory in /var/www/html/example.php on line 22
    Fatal error: Call to undefined function fact() in /var/www/html/test.php on line 8

    My php file and .c .i file resides in /var/www/html folder.
    I am compiling the file in same folder. So .so an other files are created to same folder
    also extension in php.ini is given to /var/www/html/example.so

    Still i am getting the above error.

    What is the remidy?

    Regards
    Dheeraj Joshi M
  • wizardry
    New Member
    • Jan 2009
    • 201

    #2
    can you elaborate for me?

    system os? from what i'm reading your using linux ? what version?

    also what is your coding environment? i.e. visual studio?

    thanks,

    theo werntz ii

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      OS LINUX( fedora core 4.)

      PHP version is php 5.3 and swig is 1.3.39

      Comment

      • wizardry
        New Member
        • Jan 2009
        • 201

        #4
        try repairing the package. i've ran into this before and just ended up going with lampp! its easier for developement. because of those errors with the lib.so i've also created a symlink to create a temp fix if you go to the directory and see that its not pointing to the file but the file is just a link of another file that it is linked to.

        let me know if this works the symlinks is a temp fix. it works then it doesn't.

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Originally posted by dheerajjoshim
          Hi..
          I am trying to call a c function from a PHP.
          But i am getting following error.

          Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/example.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/example.so: cannot open shared object file: No such file or directory in /var/www/html/example.php on line 22
          Fatal error: Call to undefined function fact() in /var/www/html/test.php on line 8

          My php file and .c .i file resides in /var/www/html folder.
          I am compiling the file in same folder. So .so an other files are created to same folder
          also extension in php.ini is given to /var/www/html/example.so

          Still i am getting the above error.

          What is the remidy?

          Regards
          Dheeraj Joshi M
          Your shared library needs to be put in the default extension_dir, as per your php.ini -- your post says it is /usr/local/lib/php/extensions/no-debug-non-zts-20090626/. Otherwise, you need to add an 'extension=/path/to/sharedob.so' to your php.ini.

          Mark.

          Comment

          • Dheeraj Joshi
            Recognized Expert Top Contributor
            • Jul 2009
            • 1129

            #6
            Hi Mark

            I even tried to add the extension = /path/..............

            But it wont work.

            In php5 and above they removed the support for dl() function.
            They want people to use extension=/path/............... ....

            But the intermediate .php file created by swig still uses the dl() function.

            It may create problem right?

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              Originally posted by dheerajjoshim
              Hi Mark

              I even tried to add the extension = /path/..............

              But it wont work.

              In php5 and above they removed the support for dl() function.
              They want people to use extension=/path/............... ....

              But the intermediate .php file created by swig still uses the dl() function.

              It may create problem right?
              It's deprecated in PHP5, yes - you can still use it, but shouldn't.

              I have no idea what SWIG is, so I cannot be of any help here. Possibly ask the developers for help?

              Mark.

              Comment

              • wizardry
                New Member
                • Jan 2009
                • 201

                #8
                hello -

                what i was trying to explain to you earlier in my post is that you need to change to this directory:
                '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/

                their look and see what sym links are going to:
                example.so

                just because swig has it in their php.ini file that variable is still loaded when you go to execute your page from the developement studio. So your still having the issue then u need to create the links. their should be atleast 3 symlinks going to the example.so example.so0 example.so1 look in the directory they should be pointing back to the main file example.so or not.

                i had to create these in my install of php5 because the lib. was not loaded even though the variable was in the config file. Their sym links were not created on install for what reason unknown.

                let us know.

                theo

                Comment

                • Dheeraj Joshi
                  Recognized Expert Top Contributor
                  • Jul 2009
                  • 1129

                  #9
                  Hi wizardry

                  I tried to give the extension from the php.ini file. but no help.

                  I am planing to reistall php.

                  Could you tell me what and all the configure parameter i must pass? I am bit confused in this issue.

                  Comment

                  • wizardry
                    New Member
                    • Jan 2009
                    • 201

                    #10
                    hello -

                    thats not going to help by reinstalling.

                    i've been in that situation as well.

                    you need to go where the error is.

                    which is:
                    '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/'

                    and then see if the example.so exists if it doesnt you should see other links their as well that are pointing to example which is the application.

                    the other .so .so1 .so2 are just symlinks for improved stack performance on install and on the server processing.

                    if you haven't reinstall yet could you post that directory contents?

                    '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/'

                    and your error log from the server and php?

                    I will repost with a possible fix thanks,

                    theo

                    Comment

                    • Dheeraj Joshi
                      Recognized Expert Top Contributor
                      • Jul 2009
                      • 1129

                      #11
                      Hi,

                      example.so do present in that directory..

                      Comment

                      • wizardry
                        New Member
                        • Jan 2009
                        • 201

                        #12
                        ok now that we know it exists can you post your appache and mysql server log, and app log when you try to execute the page.

                        instead of doing a complete reinstall and having to go through this procedure again.

                        we need to see why its not being loaded their is a symlink missing to point to the file to be executed.

                        now its diagnostic time. repost the logs and i will try to help u thats why we are here.

                        theo werntz ii

                        Comment

                        Working...