[S] Interface with C++ (responses)

Michael Wolf (mwolf@est-econ.uc3m.es)
Fri, 30 Oct 1998 17:06:48 +0100

This is a multi-part message in MIME format.
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


A while ago I asked for some pointers to using the interface with C++ on
a PC. Here are some useful answers I received. I apologize for the delay
in posting this message.


Content-Type: text/plain; charset=us-ascii; name="Cplus.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Cplus.txt"


I have done this with MSVC++ and the free mingw32 compiler.

It works for me with S+ version 4 release 3. There are some
examples on my web page. otter-rsch.com/admodel.htm.

I haven't had much luck with c++ on UNIX worksstations however.
there are unsatisfied references which has soemthing to do
with splus but they don't seem tocooperate much on that.



David A. Fournier Otter Research Ltd. PO Box 2040 Sidney, B.C. V8L
3S3 voice/fax (250) 655 3364 http://otter-rsch.com


You should look at the document "cfortran.pdf" available by going
to http://www/mathsoft.com/support/splusmenu.htm and clicking on
"Interfacing with C and Fortran Code documentation".

The short answer is that you can interface C++ code to S-PLUS 4.x
if you create 32-bit dll's and follow the guidelines in this
document. You then call them using dll.load(). Using dyn.load()
requires C code created by the Watcom 10.x compiler. You can use
dll.load() with dll's created by most any 32-bit C or C++


| Chuck Taylor Senior Quality Assurance
Engineer | | MathSoft Seattle, WA, USA chuck@statsci.com
| |
| | "All statements in this message represent the opinions of the
author | | and do not necessarily reflect official MathSoft
policy or position." |

I have used C++ and SPLUS on UNIX and on the PC it works fine if you keep a
few simple facts in mind. First and foremost, C++ mangles names.
The names of your C++ functions will not be the same in the object
file as what you named them in your source, therefore, you must
wrap the functions you wish to export in extern "C" { }
Another thing to keep in mind is that on the PC dll's are the most
efficient way to link with SPLUS (see a post from me on this
subject in the archive). DLL's can be a hassle for developing
because you must unload-load-unload-load each time you change
something. Automate this step and you will save yourself a lot of
time. Good luck,



This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news