help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Octave 3.6.4 VS2010 and the C++ API


From: Mike Puglia
Subject: Octave 3.6.4 VS2010 and the C++ API
Date: Thu, 19 Sep 2013 04:47:51 -0700 (PDT)

Hi,

I've been using the C++ API with Octave 3.6.4 gcc/Mingw for a while without any 
problems.  I've built a small static library and I know it works on this 
platform.

I'm now forced (for reasons unrelated to anything here) to compile that same 
library using MSVC tools.  My library compiles fine for Octave3.6.4/VS2010 but 
I'm having a problem linking.  Specifically I'm having problems linking to any 
of the functions defined in xdiv.h.

To demonstrate the problem I'm having, I tried compiling the simple octfile 
code below (which was taken from a post on the forum: 
https://mailman.cae.wisc.edu/pipermail/help-octave/2010-August.txt).  I used 
mkoctfile.-v and all the switches/paths look correct.

#include <octave/oct.h>
#include <octave/xdiv.h> DEFUN_DLD( backslash, args, nargout , "-*- texinfo 
-*-\n\
@deftypefn {Function File} address@hidden = } backslash (@var{A}, @var{b})\n\
Solve a linear system Ax = b. This is just a script to demonstrate how to do it 
in an octfile, because it's not so obvious...\n\
@end deftypefn\n\
\n\
Author: Stefan Hedman <schteppe@@gmail.com>\n")
{ 
octave_value retval; 
if(args.length()!=2)
{ 
print_usage(); 
return retval; 
}
Matrix b(args(0).matrix_value()); 
Matrix A(args(1).matrix_value()); 
MatrixType mt(args(1).matrix_value()); 
Matrix x = xleftdiv(b,A,mt); 
return octave_value(x);
}

This code compiles and links fine using mkoctfile on Octave 3.6.4/mingw 
(binaries downloaded from sourceforge), but when compiled using mkoctfile on 
Octave 3.6.4/VS2010 (binaries also from sourceforge), I get the following 
linker error:

backslash.o : error LNK2019: unresolved external symbol "class Matrix __cdecl 
xleftdiv(class Matrix const &,class Matrix t &,class MatrixType &,enum 
blas_trans_type)" (?xleftdiv@@YA? 
VMatrix@@address@hidden@@W4blas_trans_type@@@Z) refer in function "class 
octave_value_list __cdecl Fbackslash(class octave_value_list const &,int)" 
(?Fbackslash@@YA?AVoctave e_list@@address@hidden@Z)
backslash.oct : fatal error LNK1120: 1 unresolved externals


I'm pretty sure I've set my environment up correctly, since the code compiles, 
links and executes without problem on VS2010 platform if I change the 
xleftdiv() to b*A.  It seems that either 1) all the functions in xdiv.h are not 
exposed in the octave libs for the VS2010 build, or 2) the _cdecl decoration on 
xleftdiv() does not match the octave library.  Do either of these causes sound 
plausible?  I ran dumpbin on octinterp.lib and couldn't find any of the 
relavant functions (though I could find the relevant handles in 
liboctinterp.dll.a using nm), so I'm assuming that #1 is the more likely of two 
possible causes.

Before I look any further into this, does anyone know if the functions in 
xdiv.h are exposed in the VS2010 build on sourceforge, and if so in which lib 
file are they exposed? I've reached the extent of my skills here and thought I 
would ask before spending more time on this.

Thanks in advance for your help,

MTP


reply via email to

[Prev in Thread] Current Thread [Next in Thread]