Question

I'm trying to build a Cocoa app that connects to the Mathematica kernel. Upon building, I get the following:

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)

As the arguments state, I am linking to mathlink.framework and libstdc++.6.dylib. What am I doing wrong?

Was it helpful?

Solution

When not using mprep, you have to define certain symbols your self. I used mprep on an empty template and got this. This is the relevant section of 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 */
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top