Re: Re: No joy using gcc 2.95.3 + MathLink v3r9 + Windows 2000 SP2
- To: mathgroup at smc.vnet.net
- Subject: [mg31852] Re: [mg31621] Re: [mg31600] No joy using gcc 2.95.3 + MathLink v3r9 + Windows 2000 SP2
- From: "Matthew D. Langston" <langston at SLAC.Stanford.EDU>
- Date: Fri, 7 Dec 2001 05:56:46 -0500 (EST)
- Organization: Stanford Linear Accelerator Center
- References: <200111161138.GAA07033@smc.vnet.net> <200111181129.GAA27822@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi John, Thanks for your help. Unfortunately, we just haven't been able to find a way to use gcc and/or g77 to create working MathLink programs under Windows. I tested your theory that perhaps argc and argv were not being passed to MLMain(), but it looks like they are (unless MLScanString works differently when called from a gcc compiled program instead of a cl compiled program). I used the following WinMain program using both gcc and cl, and only the cl compiled program creates a working MathLink program. Both, however, display the "Hello from WinMain" MessageBox when I Install[] my MathLink program, so it appears to be some incompatability between gcc and MathLink. #include "mathlink.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, "Hello from WinMain!", NULL, MB_OK); char buff[512]; char FAR * buff_start = buff; char FAR * argv[32]; char FAR * FAR * argv_end = argv + 32; if( !MLInitializeIcon( hInstance, nCmdShow ) ) { return 1; } MLScanString( argv, &argv_end, &lpCmdLine, &buff_start); return MLMain( argv_end - argv, argv); } Anyway, I wanted to thank you for your help, and to inform other MathLink users not to use gcc and/or g77 under Windows to create MathLink programs. Warmest regards, Matt -- Matthew D. Langston SLD, Stanford Linear Accelerator Center langston at SLAC.Stanford.EDU ----- Original Message ----- From: "John Fultz" <jfultz at wolfram.com> To: mathgroup at smc.vnet.net Subject: [mg31852] [mg31621] Re: [mg31600] No joy using gcc 2.95.3 + MathLink v3r9 + Windows 2000 SP2 > On Fri, 16 Nov 2001 06:38:04 -0500 (EST), Matthew D. Langston wrote: > >I'm trying to recompile, using gcc 2.95.3, a library of functions > >written in C/C++ that I have already successfully exported to > >Mathematica (using MathLink) with cl.exe version 6 (from Microsoft > >Visual Studio 6.0) and cl.exe version 7 (from Microsoft Visual > >Studio.NET). > > > >I'm running Windows 2000 SP2, Mathematica 4.1, and using mldev32 from > >the MathLink Developer's Kit v3r9. The version of gcc I am using is > >2.95.3-5 from the Cygwin 1.3.5 release (which is the latest version as I > >write this). > > > >I'm linking against the ml32i2m.lib import library (the version for > >Microsoft Visual Studio 6.0). > > > >I'm passing "-mwindows" to gcc at both compile time and link time, and > >passing "-e _mainCRTStartup" to gcc at link time. This *should* give me > >an official, respectable Win32 application. And indeed, these options > >do work in creating working Win32 applications. > > > >My library of C/C++ functions compiles and links fine with all three > >compilers (i.e. gcc 2.95.3, cl.exe version 6, and cl.exe version 7). My > >functions work just fine (after Install[]ing them in Mathematica ) using > >the two Microsoft compilers, but the gcc version "appears" to hang > >Mathematica. > > > >When I run Install["Minuitgcc`"] (to load the gcc version of my MathLink > >exported functions) from within the Mathematica Front End, I get a > >dialog box with the title "MathLink" that has a "Create link:" label, a > >text entry box and an "OK" and "Cancel" button. > > > >If I click the "OK" button (without entering anything in the text box) > >then I get another dialog box with the title "MathLink" that has a "Link > >created on: 628" label and an "OK" button. > > > >My MathLink program appears in the Windows Task Manager as task > >"Minuitgcc(628)" with a status of "Running". However, Mathematica just > >hangs on the cell that executed the Install["Minuitgcc`"] command. The > >title of the Front End Mathematica window is "Running...m2c.nb" (my > >notebooks name is m2c.nb). > > > >The exact same code is being used by all three compilers (i.e. my source > >code of functions, the same mathlink.h file, the same output file from > >mprep, the same ml32i2m.lib import library, etc.). The only difference > >is the compiler/linker. > > > >Why do the two Microsoft compilers create working MathLink programs, > >while gcc doesn't? > > > >Thank you for your help. > > > >Regards, Matt > > > >-- > >Matthew D. Langston > >SLD, Stanford Linear Accelerator Center > >langston at SLAC.Stanford.EDU > > > > > > It sounds to me like the gcc version of your program isn't passing the > command-line arguments to MLMain() correctly. If I had to guess, I'd say > that gcc is using the main() startup function instead of WinMain(), and > you didn't write your main() function to correctly pass argc and argv into > MLMain(). > > Sincerely, > > John Fultz > jfultz at wolfram.com > User Interface Group > Wolfram Research, Inc. > > >