MathLink没有链接到Cocoa项目

时间:2014-05-05 07:19:01

标签: macos cocoa wolfram-mathematica linker-errors mathlink

我正在尝试构建一个连接到Mathematica内核的Cocoa应用程序。建成后,我得到以下内容:

Ld /Users/firelizzard/Library/Developer/Xcode/DerivedData/EE606_Project_3-emhkyuccnhcwxwaxlkoftpwzvicx/Build/Products/Debug/EE606\ Project\ 3.app/Contents/MacOS/EE606\ Project\ 3 normal x86_64
    cd "/Users/firelizzard/Documents/School/2013-14/Spring/EE606/EE606 Project 3"
    export MACOSX_DEPLOYMENT_TARGET=10.9
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/firelizzard/Library/Developer/Xcode/DerivedData/EE606_Project_3-emhkyuccnhcwxwaxlkoftpwzvicx/Build/Products/Debug -L/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/MacOSX-x86-64/CompilerAdditions -F/Users/firelizzard/Library/Developer/Xcode/DerivedData/EE606_Project_3-emhkyuccnhcwxwaxlkoftpwzvicx/Build/Products/Debug -F/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/MacOSX-x86-64/CompilerAdditions -filelist /Users/firelizzard/Library/Developer/Xcode/DerivedData/EE606_Project_3-emhkyuccnhcwxwaxlkoftpwzvicx/Build/Intermediates/EE606\ Project\ 3.build/Debug/EE606\ Project\ 3.build/Objects-normal/x86_64/EE606\ Project\ 3.LinkFileList -mmacosx-version-min=10.9 -fobjc-arc -fobjc-link-runtime -lstdc++.6 -framework mathlink -framework QuartzCore /Users/firelizzard/Library/Developer/Xcode/DerivedData/EE606_Project_3-emhkyuccnhcwxwaxlkoftpwzvicx/Build/Products/Debug/CorePlot.framework/CorePlot -framework AVFoundation -framework Cocoa -Xlinker -dependency_info -Xlinker /Users/firelizzard/Library/Developer/Xcode/DerivedData/EE606_Project_3-emhkyuccnhcwxwaxlkoftpwzvicx/Build/Intermediates/EE606\ Project\ 3.build/Debug/EE606\ Project\ 3.build/Objects-normal/x86_64/EE606\ Project\ 3_dependency_info.dat -o /Users/firelizzard/Library/Developer/Xcode/DerivedData/EE606_Project_3-emhkyuccnhcwxwaxlkoftpwzvicx/Build/Products/Debug/EE606\ Project\ 3.app/Contents/MacOS/EE606\ Project\ 3

Undefined symbols for architecture x86_64:
  "_MLEvaluate", referenced from:
      +[MathSpice evaluateObject:] in MathSpice.o
      +[MathSpice putError:withMessage:] in MathSpice.o
  "_stdlink", referenced from:
      +[MathSpice getObjectForPacket] in MathSpice.o
      +[MathSpice putPacketForObject:] in MathSpice.o
      +[MathSpice evaluateObject:] in MathSpice.o
      +[MathSpice putFailureResponse] in MathSpice.o
      +[MathSpice putError] in MathSpice.o
      +[MathSpice putError:withMessage:] in MathSpice.o
      +[MathFunction get] in MathFunction.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

正如参数所述,我正在链接到mathlink.framework和libstdc ++。6.dylib。我做错了什么?

1 个答案:

答案 0 :(得分:0)

不使用mprep时,您必须自己定义某些符号。我在一个空模板上使用了mprep并获得了this。这是mathlink.h的相关部分:

#ifndef _MLTM_H
#define _MLTM_H


/*************** Template interface ***************/

/* The following are useful only when using template files as
 * their definitions are produced by mprep.
 */

ML_EXTERN_C
extern MLINK stdlink;
extern MLEnvironment stdenv;

extern MLYieldFunctionObject stdyielder;
extern MLMessageHandlerObject stdhandler;

#if MLINTERFACE >= 3
extern int MLMain P((int, char **)); /* pass in argc and argv */
extern int MLMainString P(( char *commandline));
#else
extern int MLMain P((int, charpp_ct)); /* pass in argc and argv */
extern int MLMainString P(( charp_ct commandline));
#endif /* MLINTERFACE >= 3 */

extern int MLMainArgv P(( char** argv, char** argv_end)); /* note not FAR pointers */

extern int MLInstall P((MLINK));
extern mlapi_packet MLAnswer P((MLINK));
extern int MLDoCallPacket P((MLINK));
#if MLINTERFACE >= 3
extern int MLEvaluate P(( MLINK, char *));
extern int MLEvaluateString P(( MLINK, char *));
#else
extern int MLEvaluate P(( MLINK, charp_ct));
extern int MLEvaluateString P(( MLINK, charp_ct));
#endif /* MLINTERFACE >= 3 */
ML_END_EXTERN_C

#if MLINTERFACE >= 3
MLMDECL( void, MLDefaultHandler, ( MLINK, int, int));
#else
MLMDECL( void, MLDefaultHandler, ( MLINK, unsigned long, unsigned long));
#endif /* MLINTERFACE >= 3 */

#if MLINTERFACE >= 3
MLYDECL( int, MLDefaultYielder, ( MLINK, MLYieldParameters));
#else
MLYDECL( devyield_result, MLDefaultYielder, ( MLINK, MLYieldParameters));
#endif /* MLINTERFACE >= 3 */

ML_EXTERN_C
#if WINDOWS_MATHLINK
extern HWND MLInitializeIcon P(( HINSTANCE hinstCurrent, int nCmdShow));
extern HANDLE MLInstance;
extern HWND MLIconWindow;
#endif
extern int MLAbort, MLDone;
extern long MLSpecialCharacter;
ML_END_EXTERN_C

#endif /* _MLTM_H */