Group Abstract Group Abstract

Message Boards Message Boards

0
|
12K Views
|
11 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Issues with WSTP

Posted 10 years ago
11 Replies

Oh, sorry didn't see the commands you inputted. For the path, I checked already. It works on my machine too. Thank you.

POSTED BY: Ilian Gachevski
POSTED BY: Ilian Gachevski
Posted 10 years ago

What about adding -std=c++11 into the command?

POSTED BY: Shujie CHEN

Do both -stdlib=libstdc++ and -lstdc++ appear on your linker command line?

POSTED BY: Ilian Gachevski

I just made that adjustment and get an error that starts like this:

Undefined symbols for architecture x86_64:
  "std::__basic_file<char>::is_open() const", referenced from:
      WSTP::MLLog::logSelectorToFileWithName(WSTP::mllogselector, char const*) in libWSTPi4.a(mllog.cpp.o)
  "std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const", referenced from:
      mlopen_argv(ws_environment*, long, char**, void*, void*, int*) in libWSTPi4.a(mlopen.c.o)
      WSTP::MLLog::~MLLog() in libWSTPi4.a(mllog.cpp.o)
  "std::basic_ios<char, std::char_traits<char> >::widen(char) const", referenced from:
      feature_greeting(ws_environment*, WSLink*, device_kebab*, _queue*, feature_set*) in libWSTPi4.a(mlgreet.c.o)
      WSTP::MLExceptionMessage::print(std::ostream&) const in libWSTPi4.a(mlexceptions.cpp.o)
      WSTP::initSyncObjectDir() in libWSTPi4.a(mlplatformthreads.cpp.o)
      WSTP::MLLog::~MLLog() in libWSTPi4.a(mllog.cpp.o)
      WSTP::MLLog::operator()(WSTP::mllogselector) in libWSTPi4.a(mllog.cpp.o)
      WSTP::MLExprLog::writeContentsToStreams(WSTP::MLExprLog::mllogdirection&, bool, std::basic_ostringstream<char, std::char_traits<char>, WSTP::MLStdAllocator<char> >&) in libWSTPi4.a(mlexprlog.cpp.o)
      WSTP::MLInterfaceContainer::PrintInterfaceContainer(std::ostream&) const in libWSTPi4.a(mlinterface.cpp.o)
      ...

It may be the same exact one I had earlier

Prior to version 10.4, use -lstdc++ in EXTRA_LIBS to link against libstdc++ instead of libc++

(there is also an alternative set of WSTP libraries supplied if you wish to use the libc++ standard library instead).

POSTED BY: Ilian Gachevski

I am using OS X (10.11.5) with Mathematica 10. I'm attaching the make file and template files. The files cannot be attached, so I just pasted their content in here.

f.c

#include <stdio.h>
#include <stdlib.h>
#include "wstp.h"

extern int f( int i, int j);

int f(int x, int y) {
   return x+y;
}
int main(int argc, char *argv[]) {
   return WSMain(argc, argv);
}

f.tm

:Begin:
:Function:      f
:Pattern:       f[x_Integer, y_Integer]
:Arguments:     {x, y}
:ArgumentTypes: {Integer, Integer}
:ReturnType:    Integer
:End:

make

# This makefile can be used to build all or some of the sample
# programs. To build all of them, use the command
# 'make all'. To build one, say addtwo, use the command
# 'make addtwo'.

WSLINKDIR = /Applications/Mathematica.app/Contents/SystemFiles/Links/WSTP/DeveloperKit
SYS = MacOSX-x86-64
CADDSDIR = ${WSLINKDIR}/${SYS}/CompilerAdditions

INCDIR = ${CADDSDIR}
LIBDIR = ${CADDSDIR}

WSPREP = ${CADDSDIR}/wsprep

EXTRA_CFLAGS=-stdlib=libstdc++
EXTRA_LIBS = -lc++ -framework Foundation

MATHLINK_LIB = -lWSTPi4

all : f

f : ftm.o f.o
    ${CC} -I${INCDIR} ftm.o f.o -L${LIBDIR} ${MATHLINK_LIB} ${EXTRA_LIBS} -o $@

.c.o :
    ${CC} -c ${EXTRA_CFLAGS} -I${INCDIR} $<

ftm.c : f.tm
    ${WSPREP} $? -o $@

Are you on OS X? Which version of Mathematica are you using?

You may need -stdlib=libstdc++ but that's difficult to say without the above information and the actual Makefile.

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