Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: help with mathlink

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52357] Re: [mg52279] help with mathlink
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Wed, 24 Nov 2004 02:32:30 -0500 (EST)
  • Reply-to: jfultz at wolfram.com
  • Sender: owner-wri-mathgroup at wolfram.com

Your problem is that you created a Visual C++ project which compiles a 
Win32 Console Application instead of a Win32 Windows Application.  Console 
applications create a command prompt if one wasn't used to launch it, and 
their entry point is the function

int main(int argc, char **argv)

A Win32 program expects the application to create a window if output is 
necessary, and its entry point is

int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)

The addtwo example should  be compiled as a Windows Application.  You could 
use the main() function by replacing the line...

#elif WINDOWS_MATHLINK

with

#elif 0

in addtwo.c, but this is a suboptimal solution, since every time you 
Install[] addtwo, a command prompt window would appear.

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Sat, 20 Nov 2004 03:42:01 -0500 (EST), OT wrote:
> I'm trying to learn how to use mathlink, but I'm still unable tu run
>
> the simplest example provided with Mathematica (addtwo).
>
> I'm using Mathematica 4.1 and MS Visual C++ 6.0
>
> Here's the problem: I added to MS Visual c++ "project" the following
> files:
> Source files:
> - addtwo.c
> - addtwo.tm.c
> Headers files:
> - mathlink.h
> Resource files:
> - ml32i2m.lib
>
> I can compile both the 2 source files with 0 errors and 0 warnings,
> but when I try to link them to build the output - executable file I
> get the error:
>
> ----------Configuration: addtwo - Win32 Debug----------
> Compiling...
> addtwo.c
> addtwo.tm.c
> Linking...
> LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
> Debug/addtwo.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
> addtwo.exe - 2 error(s), 0 warning(s)
>
>
> I really can't understand what's wrong... I'm only trying to follow
> step-by-step the MathLink tutorial and it doesn't work... :(
>
> --
> OT


  • Prev by Date: Approximate entropy applied to the Pi digits
  • Next by Date: Re: Re: Piecewise symbol in 5.1
  • Previous by thread: Re: help with mathlink
  • Next by thread: Re: help with mathlink