Re: Using C libraries and PHP - calling functions in external libraries
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Sun, 24 Feb 2008 22:31:11 -0500
icu5545 wrote:
On Feb 23, 5:29 pm, Otis <otie_nos...@xxxxxxx> wrote:>> You might try a host that allows dynamic loading of your dll via the
dl() function.
Unfortunately, my .dll is a Windows .dll (I think it is compiled with C),
not a PHP extension - and it needs to run on my hosted UNIX server, so I
don't think you can just put a Windows .dll on a UNIX server and expect a
PHP call to it to respond properly.
Can you???
Otis
Norman Peelman wrote:Otis wrote:Currently I am running a compiled C program (called swetest) on LinuxYou might try a host that allows dynamic loading of your dll via the
from PHP using the exec() command. This allows me to get the
calculations I need. But some web hosts out there disable the exec()
command and I am stuck. What are the ways in which I might be able to
call the functions in swetest directly from PHP without having to rely
on the PHP exec() command and its buddies like system, shell_exec(),
etc., which are also disabled.
I have the following C files available:
swetest.c
libswe.a (which I guess is the created library)
On a Windows system, I can make a .dll (astro_php.dll), then call it
from PHP thusly:
$obj = new COM("astro_php.astro_php_cls");
$output=$obj->Get_geo_planet("2454507.5", "2");
echo $output;
How does one do something similar on Linux instead of Windows?
Thank you.
Otis
dl() function.
Nope, unless the server is actually running in a virtual environment
utilizing Windows as its OS. (A very long shot.) Anywho, you need a
file with the extension ".so" to run on a Linux variant. If you had
the source, you could port it to Linux using a Live CD (or plain old
install) to compile it.
Another thing that I am completely unsure about is utilizing Wine
(Windows file emulator).
NOTE: the Wine thing is a bit of a stretch in itself. I'm not actually
sure it's possible. And it certainly would / should not be possible on
shared hosting.
Correct. A Windows DLL will not run on a Unix/Linux server. It will only run under Windows - either standalone or on a virtual machine, but it must be Windows. Not even Wine will allow the DLL to run.
It would be theoretically possible to make a Windows DLL run under Linux - but it would basically require creating a Windows emulator under Linux. It's easier to just use a virtual machine.
If this MUST run under Linux/Unix, it must be recompiled. Whether it works or not will depend on how many OS-specific functions it uses.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- References:
- Using C libraries and PHP - calling functions in external libraries
- From: Otis
- Re: Using C libraries and PHP - calling functions in external libraries
- From: Norman Peelman
- Re: Using C libraries and PHP - calling functions in external libraries
- From: Otis
- Re: Using C libraries and PHP - calling functions in external libraries
- From: icu5545
- Using C libraries and PHP - calling functions in external libraries
- Prev by Date: Re: Using C libraries and PHP - calling functions in external libraries
- Next by Date: Re: Newbie question on being "crippled"
- Previous by thread: Re: Using C libraries and PHP - calling functions in external libraries
- Next by thread: PHP/GD/ Freetype : captcha for a comments form
- Index(es):
Relevant Pages
|