[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.
--------------2D5DEE4A05C80671ABD3739E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

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.

Michael

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

Hi,

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.

Cheers,

Dave

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

Michael,

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++
compiler.

Chuck

|-----------------------------------------------------------------------|
| 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." |
|-----------------------------------------------------------------------|

Michael,
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" { }
constructs.
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,

Matt


--------------2D5DEE4A05C80671ABD3739E--

-----------------------------------------------------------------------
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