Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question
    
Possible duplicate of mathematica.stackexchange.com/questions/41682/…. – Sjoerd C. de Vries Apr 9 '14 at 18:54
    
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. – user573214 Apr 9 '14 at 20:45
    
How about this question then? Especially the comments about vcvarsamd64.bat. – Sjoerd C. de Vries Apr 9 '14 at 21:19
    
I tried this as well and it didn't help. I am not seeing where vcvarsamd64.bat is mentioned though? – user573214 Apr 13 '14 at 23:17
    
It's in the comments below the question. You have to fold open the list as it is partly hidden. – Sjoerd C. de Vries Apr 14 '14 at 5:25

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"

or

"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.

share|improve this answer
    
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. – Szabolcs Jun 18 at 20:19
    
You are right. So does Wstp just duplicate ml functionality? – masterxilo Jun 19 at 9:43
    
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. – Szabolcs Jun 19 at 10:16
1  
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. – Szabolcs Jun 19 at 10:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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