1

我正在尝试编译一个用于 Mathematica 的简单 C 文件。(注意:我确实遵循了其余的说明,创建了空的 addtwotm.c 文件并添加了 addtwo.tm)

#include "mathlink.h"
extern int addtwo( int i, int j);

int addtwo( int i, int j)
{
    return i+j;
}

#if WINDOWS_MATHLINK

#if __BORLANDC__
#pragma argsused
#endif

int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
{
char  buff[512];
char FAR * buff_start = buff;
char FAR * argv[32];
char FAR * FAR * argv_end = argv + 32;

hinstPrevious = hinstPrevious; /* suppress warning */

if( !MLInitializeIcon( hinstCurrent, nCmdShow)) return 1;
MLScanString( argv, &argv_end, &lpszCmdLine, &buff_start);
return MLMain( (int)(argv_end - argv), argv);
}

#else

int main(int argc, char* argv[])
{
return MLMain(argc, argv);
}

#endif

但是,在构建时,我得到以下输出:

1>------ Build started: Project: addtwo, Configuration: Debug Win32 ------
1>  Performing Custom Build Tools
1>  on "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VC\bin\mprep.exe" "" -o "D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\addtwo\..\addtwotm.c"
1>addtwo.obj : error LNK2019: unresolved external symbol _MLMain referenced in function _WinMain@16
1>addtwo.obj : error LNK2019: unresolved external symbol _MLInitializeIcon referenced in function _WinMain@16
1>D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\Debug\addtwo.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我已按照 Wolfram 的 MathLink 开发人员指南中提供的所有说明进行操作,并确保将“ml32i3m.lib”添加到 Linker>Input>Additional Dependencies。假设 ml32/ml64 lib 文件包含 MlMain 的信息。任何帮助表示赞赏:)

4

0 回答 0