FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Running a C++ Library Function or Executable Using PHP
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Running a C++ Library Function or Executable Using PHP [message #173708] Sat, 30 April 2011 15:55 Go to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
I have an object library from code that was written in C++. Is there
a PHP call that would enable me to run a function from the library, or
a C++ derived executable, from a web page?

Thanks,
Peter.
Re: Running a C++ Library Function or Executable Using PHP [message #173709 is a reply to message #173708] Sat, 30 April 2011 16:09 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Sat, 30 Apr 2011 08:55:15 -0700, Peter Lauren wrote:

> I have an object library from code that was written in C++. Is there a
> PHP call that would enable me to run a function from the library, or a
> C++ derived executable, from a web page?

You've asked this question in both php and javascript newsgroups.

PHP runs on the server
Javascript usually runs on the client

Where do you expect this object library to be? On the client, or on the
server?

Rgds

Denis McMahon
Re: Running a C++ Library Function or Executable Using PHP [message #173710 is a reply to message #173708] Sat, 30 April 2011 18:05 Go to previous messageGo to next message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma: 0
Member
At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

>
> I have an object library from code that was written in C++. Is there
> a PHP call that would enable me to run a function from the library, or
> a C++ derived executable, from a web page?

If the library is on the server, than you can look at SWIG
(www.swig.org) to create a wrapper module. If the C++ executable is on
the server, you can use the exec() call to run it from php.

If the library or executable is on the *client*, then you need to run or
call it from JavaScript (I think SWIG can build wrappers for JavaScript
as well as PHP).

>
> Thanks,
> Peter.
>

--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
Re: Running a C++ Library Function or Executable Using PHP [message #173718 is a reply to message #173710] Sun, 01 May 2011 02:54 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 30, 2:05 pm, Robert Heller <hel...@deepsoft.com> wrote:
> At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlau...@gmail..com> wrote:
>
>
>
>> I have an object library from code that was written in C++.  Is there
>> a PHP call that would enable me to run a function from the library, or
>> a C++ derived executable, from a web page?
>
> If the library is on the server, than you can look at SWIG
> (www.swig.org) to create a wrapper module.  If the C++ executable is on
> the server, you can use the exec() call to run it from php.
>
> If the library or executable is on the *client*, then you need to run or
> call it from JavaScript (I think SWIG can build wrappers for JavaScript
> as well as PHP).
>
>
>
>> Thanks,
>> Peter.
>
> --
> Robert Heller             -- 978-544-6933 / hel...@deepsoft.com
> Deepwoods Software        --http://www.deepsoft.com/
> ()  ascii ribbon campaign -- against html e-mail
> /\  www.asciiribbon.org  -- against proprietary attachments

Thanks for the info. Robert but it would appear that C++ is not one of
the languages that is supported by SWIG although SWIG is implemented
in C++.
http://www.swig.org/compat.html#SupportedLanguages

I guess I will make executables and run them using exec() from PHP.

Thanks,
Peter.
Re: Running a C++ Library Function or Executable Using PHP [message #173720 is a reply to message #173718] Sun, 01 May 2011 12:29 Go to previous messageGo to next message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma: 0
Member
At Sat, 30 Apr 2011 19:54:02 -0700 (PDT) Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

>
> On Apr 30, 2:05=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
>> At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlau...@gmail=
> .com> wrote:
>>
>>
>>
>>> I have an object library from code that was written in C++. =A0Is there
>>> a PHP call that would enable me to run a function from the library, or
>>> a C++ derived executable, from a web page?
>>
>> If the library is on the server, than you can look at SWIG
>> (www.swig.org) to create a wrapper module. =A0If the C++ executable is on
>> the server, you can use the exec() call to run it from php.
>>
>> If the library or executable is on the *client*, then you need to run or
>> call it from JavaScript (I think SWIG can build wrappers for JavaScript
>> as well as PHP).
>>
>>
>>
>>> Thanks,
>>> Peter.
>>
>> --
>> Robert Heller =A0 =A0 =A0 =A0 =A0 =A0 -- 978-544-6933 / hel...@deepsoft.c=
> om
>> Deepwoods Software =A0 =A0 =A0 =A0--http://www.deepsoft.com/
>> () =A0ascii ribbon campaign -- against html e-mail
>> /\ =A0www.asciiribbon.org=A0 -- against proprietary attachments
>
> Thanks for the info. Robert but it would appear that C++ is not one of
> the languages that is supported by SWIG although SWIG is implemented
> in C++.
> http://www.swig.org/compat.html#SupportedLanguages

SWIG DOES support C++! You are misunderstanding the above URL. It is
the list of supported *scripting* languages (PHP is supported as of
swig-1.3.11). There is never a reason to write a wrapper for C++ for
calling C++ functions. SWIG generates wrappers for *scripting
languates* (such as PHP) to call *compiled* languages including *both*
C AND C++ and it actually also works for FORTRAN, and likely any other
*compiled* language that can be called from C (like Pascal, Ada, Cobol,
etc.). SWIG actually generats C or C++ code.

>
> I guess I will make executables and run them using exec() from PHP.
>
> Thanks,
> Peter.
>

--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
Re: Running a C++ Library Function or Executable Using PHP [message #173723 is a reply to message #173720] Sun, 01 May 2011 22:24 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On May 1, 8:29 am, Robert Heller <hel...@deepsoft.com> wrote:
> At Sat, 30 Apr 2011 19:54:02 -0700 (PDT) Peter Lauren <peterdlau...@gmail..com> wrote:
>
>
>
>
>
>> On Apr 30, 2:05=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
>>> At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlau...@gmail=
>> .com> wrote:
>
>>>> I have an object library from code that was written in C++. =A0Is there
>>>> a PHP call that would enable me to run a function from the library, or
>>>> a C++ derived executable, from a web page?
>
>>> If the library is on the server, than you can look at SWIG
>>> (www.swig.org) to create a wrapper module. =A0If the C++ executable is on
>>> the server, you can use the exec() call to run it from php.
>
>>> If the library or executable is on the *client*, then you need to run or
>>> call it from JavaScript (I think SWIG can build wrappers for JavaScript
>>> as well as PHP).
>
>>>> Thanks,
>>>> Peter.
>
>>> --
>>> Robert Heller =A0 =A0 =A0 =A0 =A0 =A0 -- 978-544-6933 / hel...@deepsoft.c=
>> om
>>> Deepwoods Software =A0 =A0 =A0 =A0--http://www.deepsoft.com/
>>> () =A0ascii ribbon campaign -- against html e-mail
>>> /\ =A0www.asciiribbon.org=A0-- against proprietary attachments
>
>> Thanks for the info. Robert but it would appear that C++ is not one of
>> the languages that is supported by SWIG although SWIG is implemented
>> in C++.
>> http://www.swig.org/compat.html#SupportedLanguages
>
> SWIG DOES support C++!  You are misunderstanding the above URL.  It is
> the list of supported *scripting* languages (PHP is supported as of
> swig-1.3.11).  There is never a reason to write a wrapper for C++ for
> calling C++ functions.  SWIG generates wrappers for *scripting
> languates* (such as PHP) to call *compiled* languages including *both*
> C AND C++ and it actually also works for FORTRAN, and likely any other
> *compiled* language that can be called from C (like Pascal, Ada, Cobol,
> etc.).  SWIG actually generats C or C++ code.
>
>
>
>> I guess I will make executables and run them using exec() from PHP.
>
>> Thanks,
>> Peter.
>
> --
> Robert Heller             -- 978-544-6933 / hel...@deepsoft.com
> Deepwoods Software        --http://www.deepsoft.com/
> ()  ascii ribbon campaign -- against html e-mail
> /\  www.asciiribbon.org  -- against proprietary attachments

Hi Robert,

Thanks for the info. I have a large number of C++ classes. Would
SWIG be the better way to go or would writing executables and using
PHP exec() be better. I know how to do the latter but thr former my
be more efficient.

Thanks,
Peter.
Re: Running a C++ Library Function or Executable Using PHP [message #173724 is a reply to message #173720] Sun, 01 May 2011 23:17 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On May 1, 8:29 am, Robert Heller <hel...@deepsoft.com> wrote:
> At Sat, 30 Apr 2011 19:54:02 -0700 (PDT) Peter Lauren <peterdlau...@gmail..com> wrote:
>
>
>
>
>
>> On Apr 30, 2:05=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
>>> At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlau...@gmail=
>> .com> wrote:
>
>>>> I have an object library from code that was written in C++. =A0Is there
>>>> a PHP call that would enable me to run a function from the library, or
>>>> a C++ derived executable, from a web page?
>
>>> If the library is on the server, than you can look at SWIG
>>> (www.swig.org) to create a wrapper module. =A0If the C++ executable is on
>>> the server, you can use the exec() call to run it from php.
>
>>> If the library or executable is on the *client*, then you need to run or
>>> call it from JavaScript (I think SWIG can build wrappers for JavaScript
>>> as well as PHP).
>
>>>> Thanks,
>>>> Peter.
>
>>> --
>>> Robert Heller =A0 =A0 =A0 =A0 =A0 =A0 -- 978-544-6933 / hel...@deepsoft.c=
>> om
>>> Deepwoods Software =A0 =A0 =A0 =A0--http://www.deepsoft.com/
>>> () =A0ascii ribbon campaign -- against html e-mail
>>> /\ =A0www.asciiribbon.org=A0-- against proprietary attachments
>
>> Thanks for the info. Robert but it would appear that C++ is not one of
>> the languages that is supported by SWIG although SWIG is implemented
>> in C++.
>> http://www.swig.org/compat.html#SupportedLanguages
>
> SWIG DOES support C++!  You are misunderstanding the above URL.  It is
> the list of supported *scripting* languages (PHP is supported as of
> swig-1.3.11).  There is never a reason to write a wrapper for C++ for
> calling C++ functions.  SWIG generates wrappers for *scripting
> languates* (such as PHP) to call *compiled* languages including *both*
> C AND C++ and it actually also works for FORTRAN, and likely any other
> *compiled* language that can be called from C (like Pascal, Ada, Cobol,
> etc.).  SWIG actually generats C or C++ code.
>
>
>
>> I guess I will make executables and run them using exec() from PHP.
>
>> Thanks,
>> Peter.
>
> --
> Robert Heller             -- 978-544-6933 / hel...@deepsoft.com
> Deepwoods Software        --http://www.deepsoft.com/
> ()  ascii ribbon campaign -- against html e-mail
> /\  www.asciiribbon.org  -- against proprietary attachments

Hi Robert,

Thanks for the info. I have a large number of C++ classes. Would
SWIG be the better way to go or would writing executables and using
PHP exec() be better. I know how to do the latter but thr former my
be more efficient.

Thanks,
Peter.
Re: Running a C++ Library Function or Executable Using PHP [message #173725 is a reply to message #173720] Sun, 01 May 2011 23:46 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On May 1, 8:29 am, Robert Heller <hel...@deepsoft.com> wrote:
> At Sat, 30 Apr 2011 19:54:02 -0700 (PDT) Peter Lauren <peterdlau...@gmail..com> wrote:
>
>
>
>
>
>> On Apr 30, 2:05=A0pm, Robert Heller <hel...@deepsoft.com> wrote:
>>> At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlau...@gmail=
>> .com> wrote:
>
>>>> I have an object library from code that was written in C++. =A0Is there
>>>> a PHP call that would enable me to run a function from the library, or
>>>> a C++ derived executable, from a web page?
>
>>> If the library is on the server, than you can look at SWIG
>>> (www.swig.org) to create a wrapper module. =A0If the C++ executable is on
>>> the server, you can use the exec() call to run it from php.
>
>>> If the library or executable is on the *client*, then you need to run or
>>> call it from JavaScript (I think SWIG can build wrappers for JavaScript
>>> as well as PHP).
>
>>>> Thanks,
>>>> Peter.
>
>>> --
>>> Robert Heller =A0 =A0 =A0 =A0 =A0 =A0 -- 978-544-6933 / hel...@deepsoft.c=
>> om
>>> Deepwoods Software =A0 =A0 =A0 =A0--http://www.deepsoft.com/
>>> () =A0ascii ribbon campaign -- against html e-mail
>>> /\ =A0www.asciiribbon.org=A0-- against proprietary attachments
>
>> Thanks for the info. Robert but it would appear that C++ is not one of
>> the languages that is supported by SWIG although SWIG is implemented
>> in C++.
>> http://www.swig.org/compat.html#SupportedLanguages
>
> SWIG DOES support C++!  You are misunderstanding the above URL.  It is
> the list of supported *scripting* languages (PHP is supported as of
> swig-1.3.11).  There is never a reason to write a wrapper for C++ for
> calling C++ functions.  SWIG generates wrappers for *scripting
> languates* (such as PHP) to call *compiled* languages including *both*
> C AND C++ and it actually also works for FORTRAN, and likely any other
> *compiled* language that can be called from C (like Pascal, Ada, Cobol,
> etc.).  SWIG actually generats C or C++ code.
>
>
>
>> I guess I will make executables and run them using exec() from PHP.
>
>> Thanks,
>> Peter.
>
> --
> Robert Heller             -- 978-544-6933 / hel...@deepsoft.com
> Deepwoods Software        --http://www.deepsoft.com/
> ()  ascii ribbon campaign -- against html e-mail
> /\  www.asciiribbon.org  -- against proprietary attachments

Hi Robert,

Thanks for the info. I have a large number of C++ classes. Would
SWIG be the better way to go or would writing executables and using
PHP exec() be better. I know how to do the latter but thr former my
be more efficient.

Thanks,
Peter.
Re: Running a C++ Library Function or Executable Using PHP [message #173726 is a reply to message #173723] Sun, 01 May 2011 23:49 Go to previous message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma: 0
Member
At Sun, 1 May 2011 15:24:09 -0700 (PDT) Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

>
> On May 1, 8:29=A0am, Robert Heller <hel...@deepsoft.com> wrote:
>> At Sat, 30 Apr 2011 19:54:02 -0700 (PDT) Peter Lauren <peterdlau...@gmail=
> .com> wrote:
>>
>>
>>
>>
>>
>>> On Apr 30, 2:05=3DA0pm, Robert Heller <hel...@deepsoft.com> wrote:
>>>> At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlau...@g=
> mail=3D
>>> .com> wrote:
>>
>>>> > I have an object library from code that was written in C++. =3DA0Is=
> there
>>>> > a PHP call that would enable me to run a function from the library,=
> or
>>>> > a C++ derived executable, from a web page?
>>
>>>> If the library is on the server, than you can look at SWIG
>>>> (www.swig.org) to create a wrapper module. =3DA0If the C++ executable=
> is on
>>>> the server, you can use the exec() call to run it from php.
>>
>>>> If the library or executable is on the *client*, then you need to run=
> or
>>>> call it from JavaScript (I think SWIG can build wrappers for JavaScri=
> pt
>>>> as well as PHP).
>>
>>>> > Thanks,
>>>> > Peter.
>>
>>>> --
>>>> Robert Heller =3DA0 =3DA0 =3DA0 =3DA0 =3DA0 =3DA0 -- 978-544-6933 / h=
> el...@deepsoft.c=3D
>>> om
>>>> Deepwoods Software =3DA0 =3DA0 =3DA0 =3DA0--http://www.deepsoft.com/
>>>> () =3DA0ascii ribbon campaign -- against html e-mail
>>>> /\ =3DA0www.asciiribbon.org=3DA0-- against proprietary attachments
>>
>>> Thanks for the info. Robert but it would appear that C++ is not one of
>>> the languages that is supported by SWIG although SWIG is implemented
>>> in C++.
>>> http://www.swig.org/compat.html#SupportedLanguages
>>
>> SWIG DOES support C++! =A0You are misunderstanding the above URL. =A0It i=
> s
>> the list of supported *scripting* languages (PHP is supported as of
>> swig-1.3.11). =A0There is never a reason to write a wrapper for C++ for
>> calling C++ functions. =A0SWIG generates wrappers for *scripting
>> languates* (such as PHP) to call *compiled* languages including *both*
>> C AND C++ and it actually also works for FORTRAN, and likely any other
>> *compiled* language that can be called from C (like Pascal, Ada, Cobol,
>> etc.). =A0SWIG actually generats C or C++ code.
>>
>>
>>
>>> I guess I will make executables and run them using exec() from PHP.
>>
>>> Thanks,
>>> Peter.
>>
>> --
>> Robert Heller =A0 =A0 =A0 =A0 =A0 =A0 -- 978-544-6933 / hel...@deepsoft.c=
> om
>> Deepwoods Software =A0 =A0 =A0 =A0--http://www.deepsoft.com/
>> () =A0ascii ribbon campaign -- against html e-mail
>> /\ =A0www.asciiribbon.org=A0 -- against proprietary attachments
>
> Hi Robert,
>
> Thanks for the info. I have a large number of C++ classes. Would
> SWIG be the better way to go or would writing executables and using
> PHP exec() be better. I know how to do the latter but thr former my
> be more efficient.

Unless your classes are doing something really exotic, SWIG will do 99%
of the work interfacing between PHP and C++. You'd mostly just use
SWIG's 'include' statement and include the header files and SWIG will go
from there.

>
> Thanks,
> Peter.
>

--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Html code beautifier
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 02:57:32 GMT 2024

Total time taken to generate the page: 0.02524 seconds