1
$\begingroup$

I am trying to follow this tutorial to compile the example addtwo program. But I am stuck on how to include the files libMLi3.a, mathlink.h and mathlink.framework to the project. Xcode seems to have changed enough since the tutorial was written (2008) that it's not clear how to add these files to the project. (I am very familiar with how to write programs in C, but I'm much less familiar with Xcode)

More generally, is there an updated tutorial that explains how to write a C program with MathLink on Mac OS X 10.10+ with Xcode 7+ that will be called from the Mathematica kernel?

$\endgroup$
6
  • 1
    $\begingroup$ Why not do it from inside Mathematica instead of from Xcode? I use CreateLibrary[] and LibraryFunctionLoad[]. It seems to handle the compiling, including, linking, and loading honky-dory. See this example. $\endgroup$
    – Mark Adler
    Commented Mar 28, 2016 at 0:22
  • $\begingroup$ @MarkAdler any alternative that works is welcome. But, I learn best by example; is there a short tutorial summarizing the steps to properly compile and link the addtwo program using CreateLibrary[] and LibraryFunctionLoad[]? If not, would you write a short answer including one? $\endgroup$
    – QuantumDot
    Commented Mar 28, 2016 at 10:29
  • $\begingroup$ Did you consider looking at the documentation? $\endgroup$
    – Mark Adler
    Commented Mar 28, 2016 at 13:25
  • $\begingroup$ I think the tutorial you are trying is quite old. You can try following tutorial from mathematica documentation "tutorial/WSTPDeveloperGuide-Macintosh" and follow the section "Building Mac OS X WSTP Programs with Xcode". $\endgroup$
    – dsingh
    Commented Mar 30, 2016 at 15:05
  • $\begingroup$ @dsingh I didn't think that there would be an updated version of that page in Mathematica 10.4 (10.3 and earlier have the older instructions). Thanks. Would you please add your comment as an answer? $\endgroup$
    – QuantumDot
    Commented Mar 30, 2016 at 15:10

1 Answer 1

2
$\begingroup$

I think the tutorial you are trying is quite old. You can try following tutorial from mathematica documentation "tutorial/WSTPDeveloperGuide-Macintosh" and follow the section "Building Mac OS X WSTP Programs with Xcode".The instructions provided in the tutorial will tell you how to include files in your xcode project as asked in the question.

$\endgroup$
2
  • 1
    $\begingroup$ I had written my reply as a comment originally but the user asked me to write it as an answer. Don't know why?.I have modified my answer to clarify my reply anyway. $\endgroup$
    – dsingh
    Commented Mar 30, 2016 at 22:37
  • $\begingroup$ I must have missed that. Apologies. $\endgroup$
    – RunnyKine
    Commented Mar 30, 2016 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.