MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MathLink and C++ (can mathlink handle C++?)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3721] Re: MathLink and C++ (can mathlink handle C++?)
  • From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
  • Date: Wed, 10 Apr 1996 02:13:50 -0400
  • Organization: University of Colorado, Boulder
  • Sender: owner-wri-mathgroup at wolfram.com

In article <4kd3eu$93v at dragonfly.wolfram.com>,
Penano Joe <penano at physics.ucla.edu> wrote:
>Hi everyone,
>
>Does anyone know if it's currently possible to intstall an
>external C++ function through mathlink?  The function
>I'm considering is very simple. It takes 3 doubles and returns 2
>doubles. I've tried defining the function as an extern in C and 
>passing the C program to mathlink but it can never find the C++
>function.  Any help would be greatly appreciated.

The problem is that C++ "munges" function names so that the linker can
check type signatures.  You need to tell the compiler not to
munge this function name.  Now I haven't tried this in a long time,
but I know that from within a C++ program you can refer to external
C functions like this:

    extern "C" {foo();}

Then you can call foo from your C++ code and the linking will work.
I'm not sure if it's possible to use this construct to tell the compiler
that you want a C++ function defined in a file to be exported with
a non-C++ name.  In any event this is almost certainly implementation
dependent, so you should check the docs for  your particular
development environment.  Maybe this will give you a starting point
for where to look.  Good luck, and let me know what happens.

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at princon.com
		http://www.princon.com/princon

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: MathLink and C++ (can mathlink handle C++?)
  • Next by Date: Re: Trig Simplifications
  • Previous by thread: Re: MathLink and C++ (can mathlink handle C++?)
  • Next by thread: Q about Nonlinear Simul. Eq