Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1308 > unrolled thread

Running a C++ Library Function or Executable Using PHP

Started byPeter Lauren <peterdlauren@gmail.com>
First post2011-04-30 08:55 -0700
Last post2011-05-01 16:46 -0700
Articles 9 — 3 participants

Back to article view | Back to comp.lang.php


Contents

  Running a C++ Library Function or Executable Using PHP Peter Lauren <peterdlauren@gmail.com> - 2011-04-30 08:55 -0700
    Re: Running a C++ Library Function or Executable Using PHP Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-04-30 16:09 +0000
    Re: Running a C++ Library Function or Executable Using PHP Robert Heller <heller@deepsoft.com> - 2011-04-30 13:05 -0500
      Re: Running a C++ Library Function or Executable Using PHP Peter Lauren <peterdlauren@gmail.com> - 2011-04-30 19:54 -0700
        Re: Running a C++ Library Function or Executable Using PHP Robert Heller <heller@deepsoft.com> - 2011-05-01 07:29 -0500
          Re: Running a C++ Library Function or Executable Using PHP Peter Lauren <peterdlauren@gmail.com> - 2011-05-01 15:24 -0700
            Re: Running a C++ Library Function or Executable Using PHP Robert Heller <heller@deepsoft.com> - 2011-05-01 18:49 -0500
          Re: Running a C++ Library Function or Executable Using PHP Peter Lauren <peterdlauren@gmail.com> - 2011-05-01 16:17 -0700
          Re: Running a C++ Library Function or Executable Using PHP Peter Lauren <peterdlauren@gmail.com> - 2011-05-01 16:46 -0700

#1308 — Running a C++ Library Function or Executable Using PHP

FromPeter Lauren <peterdlauren@gmail.com>
Date2011-04-30 08:55 -0700
SubjectRunning a C++ Library Function or Executable Using PHP
Message-ID<e679b771-815f-409f-919a-9cafd8f12462@28g2000yqu.googlegroups.com>
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.

[toc] | [next] | [standalone]


#1336

FromDenis McMahon <denis.m.f.mcmahon@gmail.com>
Date2011-04-30 16:09 +0000
Message-ID<4dbc344d$0$9466$bed64819@gradwell.net>
In reply to#1308
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

[toc] | [prev] | [next] | [standalone]


#1337

FromRobert Heller <heller@deepsoft.com>
Date2011-04-30 13:05 -0500
Message-ID<Zfidnf_-tq7_0iHQnZ2dnUVZ_jqdnZ2d@posted.localnet>
In reply to#1308
At Sat, 30 Apr 2011 08:55:15 -0700 (PDT) Peter Lauren <peterdlauren@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 / heller@deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


             

[toc] | [prev] | [next] | [standalone]


#1345

FromPeter Lauren <peterdlauren@gmail.com>
Date2011-04-30 19:54 -0700
Message-ID<c3968cea-66fa-4437-ba54-2d2afbd15100@b19g2000yqg.googlegroups.com>
In reply to#1337
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.

[toc] | [prev] | [next] | [standalone]


#1347

FromRobert Heller <heller@deepsoft.com>
Date2011-05-01 07:29 -0500
Message-ID<l42dnX-yks65zyDQnZ2dnUVZ_jednZ2d@posted.localnet>
In reply to#1345
At Sat, 30 Apr 2011 19:54:02 -0700 (PDT) Peter Lauren <peterdlauren@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 / heller@deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


                                                                          

[toc] | [prev] | [next] | [standalone]


#1350

FromPeter Lauren <peterdlauren@gmail.com>
Date2011-05-01 15:24 -0700
Message-ID<a84bc749-6e9b-47d0-ba07-4a4ef54b1399@f2g2000yqf.googlegroups.com>
In reply to#1347
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.

[toc] | [prev] | [next] | [standalone]


#1353

FromRobert Heller <heller@deepsoft.com>
Date2011-05-01 18:49 -0500
Message-ID<2pmdnSlT36UNbCDQnZ2dnUVZ_u2dnZ2d@posted.localnet>
In reply to#1350
At Sun, 1 May 2011 15:24:09 -0700 (PDT) Peter Lauren <peterdlauren@gmail.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@deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


                                     

[toc] | [prev] | [next] | [standalone]


#1351

FromPeter Lauren <peterdlauren@gmail.com>
Date2011-05-01 16:17 -0700
Message-ID<e4d7b987-4145-41eb-ae7d-e05efb22dc81@m13g2000yqb.googlegroups.com>
In reply to#1347
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.

[toc] | [prev] | [next] | [standalone]


#1352

FromPeter Lauren <peterdlauren@gmail.com>
Date2011-05-01 16:46 -0700
Message-ID<6e084653-8d1f-44f1-9bd2-f42e6a38aaf4@z13g2000yqg.googlegroups.com>
In reply to#1347
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web