MathGroup Archive 1998

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

Search the Archive

Re: C++ Builder for MathLink Programs

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13910] Re: C++ Builder for MathLink Programs
  • From: bawolk at ucdavis.edu (Bruce Wolk)
  • Date: Mon, 7 Sep 1998 01:22:36 -0400
  • Organization: University of California, Davis
  • References: <6s8fui$iph@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 29 Aug 1998 05:00:02 -0400, "Larry L. Long" <long at mail.pittstate.edu>
wrote:

>Has anyone used C++ Builder for MathLink programs?  I'm currently
>getting ready to write some external functions for Mathematica and I
>only have access to C++ Builder, are there any problems in using
>Builder for this.
>
>Thanks
>Larry Long
>
>

I have had no problem connecting with the kernel FROM a C++ Builder
program, but I have yet to figure out how to create a program using
only C++ Builder with external functions to be called from Mathematica.
But C++ Builder comes with full C++ compiler (bcc32) and linker
(tlink32) and it is no problem to compile functions that can be called
from Mathematica.  I put my functions into a single unit in C++ Builder
that I test using Builder.  When everything is working on the C end I
compile that unit using the Project | Compile Unit command. Then I
process the corresponding template file using MPREP and compile it with
bcc32 and link the resulting .obj file to the .obj file from my unit
with tlink32.

Don't forget to declare all your functions external and add to your unit

#include "mathlink.h"

and the proper WinMain function:

#pragma argsused


int PASCAL WinMain( HANDLE hinstCurrent, HANDLE hinstPrevious, LPSTR
lpszCmdLine, int nCmdShow)
{
	char  buff[512];
	char FAR * buff_start = buff;
	char FAR * argv[32];
	char FAR * FAR * argv_end = argv + 32;

	if( !MLInitializeIcon( hinstCurrent, nCmdShow)) return 1;
	MLScanString( argv, &argv_end, &lpszCmdLine, &buff_start);
	return MLMain( argv_end - argv, argv); }

And don't forget to link to the   ml32i1b.lib library that comes with
the Mathlink software!  It is all in DeveloperGuide.nb.

Bruce


  • Prev by Date: Re: how can I save only the text of a notebook?
  • Next by Date: Re: Mathematica & the Mac--file locations.
  • Previous by thread: Re: Fourier transform
  • Next by thread: Integration Problems