Message Boards Message Boards

Change stdlink to other WSLINK when using WSPut @ WSTP

GROUPS:

Is it possible to create some other WSLINK instead of stdlink with WSMain function?

The following WSTP code I tested with mathematic 10.0 and it didn't work:

std::cout<<"this is a test message."<<std::endl;
WSPutString(stdlink, "test a reply message");

The error output from Mathematica is: LinkObject::linkd: Unable to communicate with closed link LinkObject[......]

However if I removed the std::cout line, it works fine. I can get the reply message on Mathematica.

I guess it is because they're all using stdlink, so I would like to change to another WSLINK. Is it possible to change it?

POSTED BY: chad andy
Answer
7 days ago

Are you creating an installable MathLink program?

If yes, and if you followed the structure shown for the main/WinMain functions in the examples (e.g. addtwo.c) precisely, then this error likely indicates that your program is crashing. It's hard to tell why without a complete example.

What I can say with certainty though is that using the name stdlink has absolutely nothing to do with this, and there is no relationship between iostreams (std::cout) and MathLink/WSTP.

POSTED BY: Szabolcs Horvát
Answer
7 days ago

Group Abstract Group Abstract