Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

MathLink in Vista

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109976] MathLink in Vista
  • From: William Horowitz <horowitz at physics.ohio-state.edu>
  • Date: Thu, 27 May 2010 06:43:55 -0400 (EDT)
  • Organization: Ohio State University

Dear All,

I've been picking at this problem for the last two days, and I'm pretty
much at my wit's end.  I'm looking to receive data from canned FORTRAN
software from within Mathematica.  My sense is that this will be most
easily achieved by compiling the necessary code in Cygwin, which I have
running on my machine along with 64-bit Vista and Mathematica 7.0.

As a first baby step I tried to compile and Install addtwo, but I seem to
be having trouble with properly linking the .o objects together properly
(the precompiled version of addtwo Installs and works just fine).  I have
placed mathlink.h, ml64i2.dll, ml64i3.dll, ml64i3m.lib, mlmodule64.dll,
mlshm64.mlp, mltcp64.mlp, mltcpip64.mlp, mprep.exe, addtwo.c, and
addtwo.tm all in one folder.  I have also placed the dll's and mlp's in
Windows/System32.  Essentially following the steps laid out in the
makefile posted in
http://forums.wolfram.com/mathgroup/archive/2007/Jun/msg01337.html I typed
in the commands

./mprep addtwo.tm -o addtwotm.c

gcc -c -mno-cygwin -mwin32 -I./ addtwotm.c

gcc -c -mno-cygwin -mwin32 -I./ addtwo.c

gcc -I./ addtwotm.o addtwo.o -L./ -lML64i3m -mwindows -o addtwo.exe

Everything seems fine until I execute the last line.  I then get a large
number of undefined references spit back at me that finishes with a
"collect2: ld returned 1 exit status."  The first few lines of undefined
reference comments are:
addtwotm.o:addtwotm.c:(.text+0x2ef): undefined reference to
`_MLGetInteger@8'
addtwotm.o:addtwotm.c:(.text+0x30d): undefined reference to
`_MLGetInteger@8'
addtwotm.o:addtwotm.c:(.text+0x321): undefined reference to
`_MLNewPacket@4'
addtwotm.o:addtwotm.c:(.text+0x363): undefined reference to
`_MLPutFunction@12'

I then gave up on trying to use Cygwin and tried to follow the
MathLinkDevelopmentInC.pdf guide step by step.  However, I seemed to run
into the same problem.  I downloaded Visual Studio C++ 2010 Express.  I
placed mprep.exe in Program Files (x86)\Microsoft Visual Studio
10.0\VC\bin, mathlink.h in \VC\include, and the four .lib's mentioned
above in \VC\lib.  Just for the sake of overkill I also placed all these
files together with addtwo.c and addtwo.tm in a single folder.  After
opening up the Visual Studio command prompt and navigating to the correct
folder, I typed in the commands as laid out in the guide:

SET CL=/nologo /c /DWIN32 /D_WINDOWS /W3 /O2 /DNDEBUG

SET LINK=/NOLOGO /SUBSYSTEM:windows /INCREMENTAL:no /PDB:NONE kernel32.lib
user32.lin gdi32.lib

MPREP addtwo.tm -o addtwotm.c

CL addtwo.c addtwotm.c
(this generated the following output:
addtwo.c
addtwotm.c
Generating Code...)

LINK addtwo.obj addtwotm.obj ml64i3m.lib /OUT:addtwo.exe

Executing that final command yielded a string of errors:
addtwo.obj : error LNK2019: unresolved external symbol _MLScanString@16
refereced in function _WinMain@16
addtwotm.obj : error LNK2019: unresolved external symbol _MLPutInteger@8
refereced in function __tr0
addtwotm.obj : error LNK2019: unresolved external symbol _MLNewPacket@4
refereced in function __tr0
...
addtwo.exe : fatal error LNK1120: 27 unresolved externals

Of possible note is that I have Mathematica 5.2 also installed on my
machine.  I *believe* I installed 5.2 first, but don't remember exactly.
I have made sure that the files mentioned above in Windows/System32 are
all from 7.0.  Any help or advice that the community can give would be
enormously appreciated.  Thanks in advance!

Sincerely,
Will

-------------------------
William Horowitz
Postdoctoral Researcher
Department of Physics
The Ohio State University
191 West Woodruff Avenue
Columbus, OH 43210, USA
-------------------------


  • Prev by Date: Re: Trouble with Unevaluated
  • Next by Date: Problem in Mathematica 7
  • Previous by thread: the Operate[] function
  • Next by thread: Problem in Mathematica 7