Message Boards Message Boards

2
|
8073 Views
|
3 Replies
|
6 Total Likes
View groups...
Share
Share this post:

WSTP Development in C (Mac OS X)

I followed the manual exactly in order to try to compile the 'addtwo' example before continuing:

https://reference.wolfram.com/language/tutorial/WSTPDeveloperGuide-Macintosh.html

I'm however not an expert in compiling/c++, but after long fiddling around I found out that the makefile is incorrect, and I had to change two lines to make it work, original:

CADDSDIR = ${WSLINKDIR}/${SYS}/CompilerAdditions
MATHLINK_LIB = -lMLi4

changed:

CADDSDIR = ${WSLINKDIR}/${SYS}/CompilerAdditions/AlternativeLibraries
MATHLINK_LIB = -lWSTPi4

Then using commands as provided in the documentation worked:

wsprep addtwo.tm -o addtwotm.c
make addtwo

I have a feeling more people will have this problem, so I'd better post it here. I'm not sure if this is erroneous in the documentation or machine-specific.

POSTED BY: Sander Huisman
3 Replies

Yes, this is a documentation bug. If you look at the actual Makefile in the layout, $InstallationDirectory/SystemFiles/Links/WSTP/DeveloperKit/MacOSX-x86-64/WSTPExamples/Makefile, it is correct.

The difference between the libraries in CompilerAdditions and the ones in AlternativeLibraries is the usage of the libstdc++ runtime vs libc++. Since Apple changed the default in recent versions of OS X/Xcode, one should either add the -stdlib=libstdc++ flag with the first set of libraries, or else use the alternative set.

POSTED BY: Ilian Gachevski

Thanks for confirming! I missed the makefile, but indeed there is one. I copied the one from the documentation. @Ilian Gachevski, as you are an employee at WR; could you report it? It is quite an easy fix... Thanks!

POSTED BY: Sander Huisman

Dependently on how one treats it it is an error or not. the lib lMLi4 refers to Mathlink whereas lWSTPi4 refers to WSTP bindings. In my opinion the tutorial is bit obsolete. Had the same issue on Windows.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract