Dear Kia,
yes, not sure what happened. Below the original text.
Thanks
Marco
Why is the following not working?
C code: simple.c
// Inclusion of standard header files
#include <stdio.h>
int main (void)
{
int a, b, c;
a = 4;
b = 3;
c = a + b;
printf("Result is %d\n", c);
return c;
}
C++ wrapper: simple_wrap.cpp
#include <octave/oct.h>
extern "C" int simple (void);
DEFUN_DLD (simple, args, nargout, "simple test")
{
int nargin = args.length ();
octave_value_list retval;
octave_stdout << "simple test "
<< nargin << " input arguments and "
<< nargout << " output arguments.\n";
simple();
retval(0) = 1;
return retval;
}
Then:
octave:32> mkoctfile simple_wrap.cpp simple.c
octave:33> simple
error: 'simple' undefined near line 1 column 1
Please keep the mailing list in the cc, so others may benefit from our discussion.
Your file "simple.c" should not define a "main", but a "simple" function:
#include <stdio.h>
int simple (void)
{
int a, b, c;
a = 4;
b = 3;
c = a + b;
printf("Result is %d\n", c);
return c;
}
Then compile with "mkoctfile -o simple.oct simple_wrap.cpp simple.c", to create "simple.oct" instead of "simple_wrap.oct".
HTH,
Kai