1

I am relearning C++ so I can create C++ programs and run them inside Wolfram Language. I am installing the environment for writing C++. Can someone suggest the best and minimalist one which works best and what compiler is best supported with WSTP on Windows?

Also a side question, I have a very small SSD in which I have windows and Wolfram language installed, I am planning to add Visual Studio for creating C++ programs that are WSTP compatible. Can someone suggest the minimal options to choose below to make everything work with basic intellisense.

enter image description here

I don't like Visual Studio much but it is the only environment I used when I first learned C++ more than 5 years ago and want to refresh and learn how to create WSTP compatible C++ programs that I can call from inside Wolfram Language using Install.

Do people here have a preference for any particular environment and compiler that they use when creating WSTP programs (in Windows)? I am going for Visual Studio but it is a bloated program so any suggestions to make it less bloated and fast or another good program or compiler.

user13892
  • 9,375
  • 1
  • 13
  • 41
  • I think only the Visual Studio compiler is fully supported. However, you do not need the IDE. You only need the compiler (assuming you're happy compiling from the command line). BTW you can extend Mathematica also through LibraryLink, not only MathLink/WSTP. – Szabolcs Oct 13 '19 at 18:24
  • @Szabolcs I saw in a video that to make WSTP c++ code work, I have to add wstp.h header file into my cpp and the library wstp64i4m.lib into the Additional Dependencies for the Linker in Visual Studio and wstp64i4.dll into the project binary. Then I have to create a template file to link the c++ function to a mathematica symbol with calling pattern then run it through wsprep.exe. Finally Install from mathematica then will create a link to the function. How is library link different, i.e. what gymnastics will I have to play to make it work? Are they both the same technology? – user13892 Oct 13 '19 at 19:55
  • The LibraryLink user guide discusses this: http://reference.wolfram.com/language/LibraryLink/tutorial/Overview.html If you use MathLink, your program runs in a separate process. If you use LibraryLink, it runs in the kernel process. Sharing data between your code and Mathematica can be much faster with LibraryLink. You can still use the MathLink/WSTP API with LibraryLink stuff, but it requires a deeper understanding of MathLink than creating installable MathLink programs. – Szabolcs Oct 14 '19 at 07:36
  • @Szabolcs does that means LibraryLink may be unsafe for learning purposes since if c++ code is running in the same process as the kernel so anything wrong with c++ can crash the wolfram kernel as well? What is the official / preferred / well supported way to run c++ code in wolfram language, WSTP or LibraryLink? Can you also suggest some (video) tutorials to learn the command line syntax for MSVC without the IDE? – user13892 Oct 14 '19 at 14:49
  • Both are supported. I do not know of any tutorials off-hand ... I would also have to search for them. If you are not yet comfortable with C++, the best way to learn it may not be through Mathematica. Other than that, the fact that you are learning does not need to be a consideration when choosing between LibraryLink or MathLink. – Szabolcs Oct 14 '19 at 15:06
  • I suggest you check this out: https://mathematica.stackexchange.com/q/8438/12 Arnoud Buzing's LibraryLink tutorial series (which is linked from his answer) is excellent. These do assume that you are already comfortable with using a C compiler. Unfortunately, I can't help you specifically with MSVC as I do not use Windows myself ... – Szabolcs Oct 14 '19 at 15:08

0 Answers0