I was needing to use Mathlink to call some c++ code so I thought I would learn from the basic examples but I am running into strange issue. Following the procedure outlined from the Mathematica Documentation Center I attempted to do the very simple addtwo.exe build. I followed as exactly as I could(since this was written for Visual Studio 2010 some of the names of things weren't exactly the same). When I did the portion where you build addtwo using the Visual Studio Command Line Tools it works great. However, when I try to do the method outlined at "Using the Integrated Development Environment Visual Studio 2010" I get that it isn't able to find the right libraries. And get the following:

1>------ Build started: Project: addtwo, Configuration: Debug Win32 ------
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>C:\Users\themadcemist\Documents\Mathematica     Mathlink\addtwo\addtwo\Debug\addtwo.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have moved, as directed by the tutorial, all the libraries etc. to their respective folders in the path "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC" (so \bin \lib \include). I am guessing perhaps I don't have something set up correctly it just confuses me that it would work with the Command Line but not with the IDE method. (I am following the 32 bit tutorial from the website)

  • $\begingroup$ Possible duplicate of mathematica.stackexchange.com/questions/41682/…. $\endgroup$ Apr 9, 2014 at 18:54
  • $\begingroup$ I gave this a try but unfortunately it didn't work. Perhaps there is another file I would need to edit since 2013 isn't yet supported officially for Mathematica 9. It isn't imperative that I be able to use the IDE. $\endgroup$
    – user573214
    Apr 9, 2014 at 20:45
  • $\begingroup$ How about this question then? Especially the comments about vcvarsamd64.bat. $\endgroup$ Apr 9, 2014 at 21:19
  • $\begingroup$ I tried this as well and it didn't help. I am not seeing where vcvarsamd64.bat is mentioned though? $\endgroup$
    – user573214
    Apr 13, 2014 at 23:17
  • $\begingroup$ It's in the comments below the question. You have to fold open the list as it is partly hidden. $\endgroup$ Apr 14, 2014 at 5:25

1 Answer 1


All the former ML* functions now start with WS*, mathlink.h is now wstp.h. When you still get linker errors, try dragging and dropping the file

"C:\Program Files\Wolfram Research\Mathematica\10.2\SystemFiles\Links\WSTP\DeveloperKit\Windows\CompilerAdditions\mldev32\lib\wstp32i4m.lib"


"C:\Program Files\Wolfram Research\Mathematica\10.2\SystemFiles\Links\WSTP\DeveloperKit\Windows-x86-64\CompilerAdditions\mldev64\lib\wstp64i4m.lib"

into your project (in the Solution explorer). The paths might be slightly different in your installation.

If you drag-and-drop add a .lib file to your project, you don't have to specify and #pragma comment(lib, "...") or Library Directories or Additional Dependencies.

  • $\begingroup$ ML functions are still available. If fact they are what Mathematica uses internally. It is absolutely not necessary to use WS functions to achieve anything. One just needs to be consistent and not mix WS stuff with ML stiff. $\endgroup$
    – Szabolcs
    Jun 18, 2016 at 20:19
  • $\begingroup$ You are right. So does Wstp just duplicate ml functionality? $\endgroup$
    – masterxilo
    Jun 19, 2016 at 9:43
  • $\begingroup$ They renamed MathLink to WSTP for marketing reasons. They also changed functions from ML to WS naming. This broke both source and binary compatibility. For backwards compatibility, now Mathematica ships with two sets of tools/libraries: one is in SystemFiles/Links/WSTP and the other is in SystemFiles/Links/MathLink. They have the exact same functionality. When one gets updated in a new version, so does the other. But they are incompatible with each other in the sense that they cannot be mixed: Use WS and link to WSTP or use ML and link to MathLink, but don't mix. $\endgroup$
    – Szabolcs
    Jun 19, 2016 at 10:16
  • 2
    $\begingroup$ Now according to the documentation, MathLink and the ML prefix are deprecated. But: LibraryLink is clearly still set up to use ML. The examples use it, CreateLibrary uses it, etc. Trying to force WS with LibraryLink is extra work, as you discovered. If you open the kernel binary with a hex editor, you'll see it uses ML names internally. If you open any LibraryLink library that ships with Mathematica and is used internally, you see ML prefix names. I don't think ML will go away. Thus despite that deprecation warning, sticking to ML still seems the best choice right now. $\endgroup$
    – Szabolcs
    Jun 19, 2016 at 10:20

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.