Message Boards Message Boards

1
|
9139 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Why can't I get the most basic WSTP demo (addtwo.c) to build and link?

Posted 10 years ago

I am trying to use WSTP and started with the addtwo demo. I converted the template file to C using wsprep, then in Visual Studio 2013, added that, the addtwo.c file, the wstp libraries and the header file to the project. It compiled as a console app but would not link, reporting that it could not find main().

The error can be seen here:

linker can't find main()

What am I doing wrong?

POSTED BY: Michael Stern
6 Replies
Posted 9 years ago

Reporting back a year later -- Among the problems here, (1) the project should never have been build as a console app; WSTP programs should be built as Win32 apps, and (2) I was including all sorts of libraries that I didn't need. Only wstp32i4.lib was needed. I have created a number of useful WSTP since.

POSTED BY: Michael Stern

Interesting, I just followed the same procedure in VS 2013 and both the Win32 and x64 addtwo.exe ran fine. Maybe clicking on the 'Debug' button would yield some clue?

POSTED BY: Ilian Gachevski

Maybe this part of the documentation is relevant

As of Version 10.0 of the Wolfram System, the Wolfram System installer no longer installs the WSTP dynamic libraries in the Windows system directory. As a WSTP developer, you will need to place the WSTP dlls in a location on your system where your applications can find the dlls.

POSTED BY: Ilian Gachevski
Posted 10 years ago

I don't think that's it; I have copies of the DLLs in the binary directory. Without them, the binary won't run when double-clicked upon but with them, it runs then crashes. The behavior from within Mathematica seems to mirror the behavior with the DLL in place, so it looks like the system is seeing the DLL.

POSTED BY: Michael Stern

Try changing line 25 of addtwo.c

 #if WINDOWS_MATHLINK

to

 #if 0
POSTED BY: Ilian Gachevski
Posted 10 years ago

That enabled it to link, but it then crashes at runtime.

enter image description here

Any suggestions?

POSTED BY: Michael Stern
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