problem with shared object file

This is a discussion on problem with shared object file within the PHP General forums, part of the PHP Programming Forums category; Hello, I'm trying to include a shared object file with the function dl(). But I always get: Warning: dl() [...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-26-2007
Marten Lehmann
 
Posts: n/a
Default problem with shared object file

Hello,

I'm trying to include a shared object file with the function dl(). But I
always get:

Warning: dl() [function.dl]: Unable to load dynamic library
'/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
object file: No such file or directory in /homepages/xyz/test.php on line 5

But it is definetely there and readable (also executable)!

I tried to include('/homepages/xyz/util.so') which gives same parsing
errors since this is not php-code, but including works, so it's actually
readable.

What is the real error behind it? How can I find out why dynamic loading
fails? Is it possibly due to different glibc versions?

Regards
Marten
Reply With Quote
  #2 (permalink)  
Old 04-26-2007
Colin Guthrie
 
Posts: n/a
Default Re: problem with shared object file

Marten Lehmann wrote:
> Hello,
>
> I'm trying to include a shared object file with the function dl(). But I
> always get:
>
> Warning: dl() [function.dl]: Unable to load dynamic library
> '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
> object file: No such file or directory in /homepages/xyz/test.php on line 5
>
> But it is definetely there and readable (also executable)!


Is your .so in turn missing any libs? "ldd /homepages/xyz/util.so"? (it
may be statically compiled anyway)

Never tried this in PHP before so other than that I don't know much.

Col.
Reply With Quote
  #3 (permalink)  
Old 04-26-2007
Colin Guthrie
 
Posts: n/a
Default Re: problem with shared object file

Marten Lehmann wrote:
> Hello,
>
> I'm trying to include a shared object file with the function dl(). But I
> always get:
>
> Warning: dl() [function.dl]: Unable to load dynamic library
> '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
> object file: No such file or directory in /homepages/xyz/test.php on line 5


Ahhhh. I got curious and looked at the docs:

http://uk.php.net/manual/en/function.dl.php


Parameters

library

This parameter is only the filename of the extension to load which
also depends on your platform. For example, the sockets extension (if
compiled as a shared module, not the default!) would be called
sockets.so on Unix platforms whereas it is called php_sockets.dll on the
Windows platform.


Are you specifying the full path or just the filename? I'm guessing the
former judging by it's location in your filesystem - e.g. not in the
right place ;)

Col.
Reply With Quote
  #4 (permalink)  
Old 04-26-2007
Stut
 
Posts: n/a
Default Re: [PHP] problem with shared object file

Marten Lehmann wrote:
> I'm trying to include a shared object file with the function dl(). But I
> always get:
>
> Warning: dl() [function.dl]: Unable to load dynamic library
> '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
> object file: No such file or directory in /homepages/xyz/test.php on line 5
>
> But it is definetely there and readable (also executable)!
>
> I tried to include('/homepages/xyz/util.so') which gives same parsing
> errors since this is not php-code, but including works, so it's actually
> readable.
>
> What is the real error behind it? How can I find out why dynamic loading
> fails? Is it possibly due to different glibc versions?


Does the lib reference other libs? I believe that if referenced libs
can't be found it'll report that error.

-Stut
Reply With Quote
  #5 (permalink)  
Old 04-26-2007
Colin Guthrie
 
Posts: n/a
Default Re: problem with shared object file

Marten Lehmann wrote:
> Hello,
>
> I'm trying to include a shared object file with the function dl(). But I
> always get:
>
> Warning: dl() [function.dl]: Unable to load dynamic library
> '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
> object file: No such file or directory in /homepages/xyz/test.php on line 5


Some other notes from the docs you may have missed. This kinda zaps it's
usefulness IMO.


Note: dl() is not supported in multithreaded Web servers. Use the
extensions statement in your php.ini when operating under such an
environment. However, the CGI and CLI build are not affected !

Note: As of PHP 5, the dl() function is deprecated in every SAPI
except CLI. Use Extension Loading Directives method instead.

Note: Since PHP 6 this function is disabled in all SAPIs, except
CLI, CGI and embed.

Note: dl() is case sensitive on Unix platforms.

Note: This function is disabled in safe mode.

Col
Reply With Quote
  #6 (permalink)  
Old 04-26-2007
Tijnema !
 
Posts: n/a
Default Re: [PHP] problem with shared object file

On 4/26/07, Marten Lehmann <lehmann@cnm.de> wrote:
> Hello,
>
> I'm trying to include a shared object file with the function dl(). But I
> always get:
>
> Warning: dl() [function.dl]: Unable to load dynamic library
> '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
> object file: No such file or directory in /homepages/xyz/test.php on line 5
>
> But it is definetely there and readable (also executable)!
>
> I tried to include('/homepages/xyz/util.so') which gives same parsing
> errors since this is not php-code, but including works, so it's actually
> readable.
>
> What is the real error behind it? How can I find out why dynamic loading
> fails? Is it possibly due to different glibc versions?
>
> Regards
> Marten


Yes, a different glibc version could be the problem.

try ldd /homepages/xyz/util.so

Tijnema
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply With Quote
  #7 (permalink)  
Old 04-27-2007
Richard Lynch
 
Posts: n/a
Default Re: [PHP] problem with shared object file

On Thu, April 26, 2007 5:48 am, Marten Lehmann wrote:
> Hello,
>
> I'm trying to include a shared object file with the function dl(). But
> I
> always get:
>
> Warning: dl() [function.dl]: Unable to load dynamic library
> '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
> object file: No such file or directory in /homepages/xyz/test.php on
> line 5
>
> But it is definetely there and readable (also executable)!
>
> I tried to include('/homepages/xyz/util.so') which gives same parsing
> errors since this is not php-code, but including works, so it's
> actually
> readable.
>
> What is the real error behind it? How can I find out why dynamic
> loading
> fails? Is it possibly due to different glibc versions?


It's possible that util.so itself is fine, but util.so needs *ANOTHER*
..so file that *it* cannot find...

You may want to check the Apache error log and /var/log/messages to
see if they have anything in them.

Also, I think dl() is going away in PHP 6, so you may want to re-think
this from the get-go...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
  #8 (permalink)  
Old 04-27-2007
Tijnema !
 
Posts: n/a
Default Re: [PHP] problem with shared object file

On 4/27/07, Richard Lynch <ceo@l-i-e.com> wrote:
> On Thu, April 26, 2007 5:48 am, Marten Lehmann wrote:
> > Hello,
> >
> > I'm trying to include a shared object file with the function dl(). But
> > I
> > always get:
> >
> > Warning: dl() [function.dl]: Unable to load dynamic library
> > '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared
> > object file: No such file or directory in /homepages/xyz/test.php on
> > line 5
> >
> > But it is definetely there and readable (also executable)!
> >
> > I tried to include('/homepages/xyz/util.so') which gives same parsing
> > errors since this is not php-code, but including works, so it's
> > actually
> > readable.
> >
> > What is the real error behind it? How can I find out why dynamic
> > loading
> > fails? Is it possibly due to different glibc versions?

>
> It's possible that util.so itself is fine, but util.so needs *ANOTHER*
> .so file that *it* cannot find...
>
> You may want to check the Apache error log and /var/log/messages to
> see if they have anything in them.
>
> Also, I think dl() is going away in PHP 6, so you may want to re-think
> this from the get-go...


Yes, if seen it is deprecated, but how could somebody include dynamic
library without editing php.ini? I was a little bit shocked when i
read i should use php.ini variable instead. I never used it, but when
i wanted to, i would only to have it loaded in that script, and not
all scripts.

Tijnema
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply With Quote
  #9 (permalink)  
Old 04-28-2007
Richard Lynch
 
Posts: n/a
Default Re: [PHP] problem with shared object file

On Fri, April 27, 2007 5:49 pm, Tijnema ! wrote:
>> Also, I think dl() is going away in PHP 6, so you may want to
>> re-think
>> this from the get-go...

>
> Yes, if seen it is deprecated, but how could somebody include dynamic
> library without editing php.ini? I was a little bit shocked when i
> read i should use php.ini variable instead. I never used it, but when
> i wanted to, i would only to have it loaded in that script, and not
> all scripts.


I also will miss 'dl' big-time, as I sometimes load in obscure
libraries that my webhost does not provide, with their permission to
do so, and with the understanding that if the libs cause problems, I
have to be ready to live without them.

There was a thread recently on Internals about possibly not killing
this feature, but I don't think it had much support.

The guys making the decisions don't use shared hosts, for the most
part, and so few people need 'dl, so they don't feel any pressing need
for 'dl' :-(

Alas, it's something that has no user-land work-around, really...

Though I guess you could use PHP to exec CLI PHP with a custom php.ini
to then do whatever it is you wanted to do, passing all the data back
and forth from web php to cli php... Ugh.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
  #10 (permalink)  
Old 04-29-2007
Tijnema !
 
Posts: n/a
Default Re: [PHP] problem with shared object file

On 4/28/07, Richard Lynch <ceo@l-i-e.com> wrote:
> On Fri, April 27, 2007 5:49 pm, Tijnema ! wrote:
> >> Also, I think dl() is going away in PHP 6, so you may want to
> >> re-think
> >> this from the get-go...

> >
> > Yes, if seen it is deprecated, but how could somebody include dynamic
> > library without editing php.ini? I was a little bit shocked when i
> > read i should use php.ini variable instead. I never used it, but when
> > i wanted to, i would only to have it loaded in that script, and not
> > all scripts.

>
> I also will miss 'dl' big-time, as I sometimes load in obscure
> libraries that my webhost does not provide, with their permission to
> do so, and with the understanding that if the libs cause problems, I
> have to be ready to live without them.
>
> There was a thread recently on Internals about possibly not killing
> this feature, but I don't think it had much support.
>
> The guys making the decisions don't use shared hosts, for the most
> part, and so few people need 'dl, so they don't feel any pressing need
> for 'dl' :-(
>
> Alas, it's something that has no user-land work-around, really...
>
> Though I guess you could use PHP to exec CLI PHP with a custom php.ini
> to then do whatever it is you wanted to do, passing all the data back
> and forth from web php to cli php... Ugh.



You have exactly the same problem as i have. My shared hosting has
safe_mode off en dl on, so i could load them :)
But i don't have access to write to the php.ini file.
Maybe we should create such workaround as you provided? Some script
that uses PHP CLI to load dynamic objects. That would be useful for
people that use shared hosting, like you and me :)

Tijnema
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:29 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0