MathGroup Archive 2009

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

Search the Archive

Re: Problem with mathlink:PLEASE HELP ME

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97683] Re: [mg97623] Problem with mathlink:PLEASE HELP ME
  • From: Chris Hill <chill at wolfram.com>
  • Date: Wed, 18 Mar 2009 04:57:39 -0500 (EST)
  • References: <200903170959.EAA17091@smc.vnet.net>

At 04:59 AM 3/17/2009, olfa wrote:
>Hi mathematica community,
>Under windows xp,I have a c++ program in which I established a
>comunication with mathematica via mathlink.
>But when my program is executed, a "Choose a MathLink Program to
>Launch" dialog box appears and ask me to choose between some
>executables. This is my code and the problem should be in the path of
>the connection.
>In this path I have chosen to launch mathkernel.exe so why the dialog box
>appears and How can I GET RID OF THIS DIALOG BOX?
>Thank you, I'm very gratefull for any help.
>
>    ml = MLOpenString(env,"-linkname \"C:\\Program Files\\Wolfram
>Research\\Mathematica\\6.0 \\MathKernel.exe\" -mathlink",&error);

I suspect that you are encountering escaping issues with your 
linkname string containing the Windows path backslashes.  Also, the 
-mathlink parameter to the kernel should be part of the 
linkname.  Here are a few different ways to address those issues:

1) Use forward slashes (which Windows XP accepts):
ml = MLOpenString("-linkname \"C:/Program Files/Wolfram 
Research/Mathematica/6.0/MathKernel.exe -mathlink\"", &error);

2) Add more escaping of the backslashes, one level for the C compiler 
and the other for MathLink:
ml = MLOpenString("-linkname \"C:\\\\Program Files\\\\Wolfram 
Research\\\\Mathematica\\\\6.0\\\\MathKernel.exe -mathlink\"");

3) You may find it more convenient to use MLOpenArgcArgv instead of 
MLOpenString, which avoids the escaping issue:
                 char* v[10];
                 int c = 0;
                 v[c++] = "-linkname";
                 v[c++] = "C:\\Program Files\\Wolfram 
Research\\Mathematica\\6.0\\MathKernel.exe -mathlink";

                 ml = MLOpenArgcArgv(env, c, v, &error);

Finally, if you are interested in suppressing the dialog box even if 
the link name was in fact incorrect you can use the MLDontBrowse option:

ml = MLOpenString(env, "-linkname badlinkname -linkoptions 
MLDontBrowse",&error);

Chris Hill
Wolfram Research 



  • Prev by Date: Playing with numerically integrated fields?
  • Next by Date: Re: Re: Slicing a surface
  • Previous by thread: Problem with mathlink:PLEASE HELP ME
  • Next by thread: Re: Problem with mathlink:PLEASE HELP ME