unable to run factor.exe
- To: mathgroup at smc.vnet.net
- Subject: [mg119698] unable to run factor.exe
- From: Amandeep.Rekhi at tatatechnologies.com
- Date: Fri, 17 Jun 2011 05:52:36 -0400 (EDT)
Hi Below I have explained the two scenario for which I tried to run the code provided by the Mathematica: Scenario I: Unable to run the exe provided factor.exe When I tried to run the exe provided by Mathematica ( Location : C:\Program Files\Wolfram Research\Mathematica\8.0\SystemFiles\Links\MathLink\DeveloperKit\Windows \PrebuiltExamples ) Below error is coming. : "Error detected by MathLink: MathLink connection was lost.." I have done all the required changes according to the link: http://reference.wolfram.com/mathematica/tutorial/MathLinkDeveloperGuide -Windows.html Please let me know if there are any other changes that need to be done before running the program. Scenario II: When tried to run the below program provided by Mathematica after compiling in VS2005 then below error is coming. "Error detected by MathLink: Connected MathLink program has closed the link, but there might still be data underway.." Process got hanged at the line marked RED in the below program: If anybody have any idea on how to solve the issue then please let me know. Thanks is advance. ////////////////// #include <stdio.h> #include <stdlib.h> #include "mathlink.h" static void init_and_openlink( int argc, char* argv[]); static void error( MLINK lp); MLENV ep = (MLENV)0; MLINK lp = (MLINK)0; int main(int argc, char* argv[]) { int pkt, n, prime, expt; long len, lenp, k; init_and_openlink( argc, argv); printf( "Integer to factor: "); #if defined(_MSC_VER) && (_MSC_VER >= 1400) scanf_s( "%d", &n); #else scanf( "%d", &n); #endif printf("vlue of n :%d\n",n); MLPutFunction( lp, "EvaluatePacket", 1L); MLPutFunction( lp, "FactorInteger", 1L); MLPutInteger( lp, n); MLEndPacket( lp); while( (pkt = MLNextPacket( lp), pkt) && pkt != RETURNPKT) { MLNewPacket( lp); if (MLError( lp)) error( lp); } printf("3333333333333"); if ( ! MLCheckFunction( lp, "List", &len)) error(lp); //Error Message :Error detected by MathLink: Connected MathLink program has closed the link, but there might still be data underway.. for (k = 1; k <= len; k++) { if (MLCheckFunction( lp, "List", &lenp) && lenp == 2 && MLGetInteger( lp, &prime) && MLGetInteger( lp, &expt) ){ printf( "%d ^ %d\n", prime, expt); }else{ error( lp); } } MLPutFunction( lp, "Exit", 0); return 0; } static void error( MLINK lp) { if( MLError( lp)){ fprintf( stderr, "Error detected by MathLink: %s.\n", MLErrorMessage(lp)); }else{ fprintf( stderr, "Error detected by this program.\n"); } exit(3); } static void deinit( void) { if( ep) MLDeinitialize( ep); } static void closelink( void) { if( lp) MLClose( lp); } static void init_and_openlink( int argc, char* argv[]) { #if MLINTERFACE >= 3 int err; #else long err; #endif /* MLINTERFACE >= 3 */ ep = MLInitialize( (MLParametersPointer)0); if( ep == (MLENV)0) exit(1); atexit( deinit); #if MLINTERFACE < 3 lp = MLOpenArgv( ep, argv, argv + argc, &err); #else lp = MLOpenArgcArgv( ep, argc, argv, &err); #endif if(lp == (MLINK)0) exit(2); atexit( closelink); } Thanks & Regards Amandeep Singh ***************************************************************************= *********************************************************************** Email Disclaimer: Information contained and transmitted by this e-mail (including any attachm= ents) is confidential, proprietary and legally privileged data of Tata Tech= nologies that is intended for use only by the addressee. If you are not the= intended recipient, you are notified that any review, use, dissemination, = distribution, copying or printing of this e-mail is strictly prohibited. Yo= u are requested to delete this e-mail or any copies immediately and notify = the sender by reply email. Internet communications cannot be guaranteed to = be timely, secure, error or virus-free. Tata Technologies does not accept = any liability for virus infected email or errors or omissions or consequenc= es which may arise as a result of this e-mail transmission. To know more ab= out Tata Technologies please visit http://www.tatatechnologies.com ***************************************************************************= *********************************************************************