help-octave
[Top][All Lists]
Advanced

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

Re: Octave 3.6.4 VS2010 and the C++ API


From: Mike Puglia
Subject: Re: Octave 3.6.4 VS2010 and the C++ API
Date: Thu, 19 Sep 2013 07:01:20 -0700 (PDT)

Thank you for the help.  You have saved me a great deal.

Off-hand, can you think of anything in the API that is exposed and can achieve the same functionality?  Specifically I'll need to somehow replicate:

extern ComplexMatrix xleftdiv (const ComplexMatrix& a, const ComplexMatrix& b, MatrixType &typ, blas_trans_type transt = blas_no_trans);

I'm guessing a complete recompile is going to be a bit beyond my abilities/resources at the moment.  I saw the scripts and pre-compiled VS2010 packages you've posted at Octave for Windows though.  Will those work for v3.6.4?  Generally, how would I proceed with a compilation?  I assume I'll need Cygwin to run the sh scripts?  Do the scripts work in conjunction with the pre-compiled libraries, so that a complete recompile would not be necessary if only the functions in xdiv.h are decorated/exposed?

Thanks again for the help.


From: Michael Goffioul <address@hidden>
To: Mike Puglia <address@hidden>
Cc: "address@hidden" <address@hidden>
Sent: Thursday, September 19, 2013 10:01 PM
Subject: Re: Octave 3.6.4 VS2010 and the C++ API

On Thu, Sep 19, 2013 at 7:47 AM, Mike Puglia <address@hidden> wrote:
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.

The functions you're looking for are not exposed in the DLL. To expose them, they should be decorated with OCTINTERP_API. There's no clear definition of the octave API, so functions are not systematically decorated. The decorator have been added so that octave can compile with MSVC, along with its oct-files and a bunch of forge packages.

If those functions can be considered as part of the API, then the decorator can be added. But this would require recompiling octave. So at the moment, I'm afraid you're a bit dead in the water. The problem does not occur with MinGW, because it's able to auto-export all symbols. MSVC is not.

Michael.




reply via email to

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