help-octave
[Top][All Lists]
Advanced

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

Re: Compiling mex file using g++/MinGW


From: david moloney
Subject: Re: Compiling mex file using g++/MinGW
Date: Wed, 28 Aug 2013 09:12:53 +0100

please ignore

I installed the mingw version and everything works fine

-David


On Wed, Aug 28, 2013 at 6:43 AM, david moloney <address@hidden> wrote:
I've tried to compile the example from the Octave website 


file mex_demo.c
  #include "mex.h"
     
     void
     mexFunction (int nlhs, mxArray *plhs[], int nrhs, 
                  const mxArray *prhs[])
     {
       mxArray *v = mxCreateDoubleMatrix (1, 1, mxREAL);
       double *data = "" (v);
       *data = ""
       plhs[0] = v;
     }
I didn't see an obvious way to configure mkoctfile to target g++/MinGW so I used the -p option to find out which environment variables to set and eventually got it to compile
Is there an easier way to configure mkoctfile I'm missing?
It also links after I hack the linker invocation (deduced using mkoctfile -v .mex_demo.c)

ld -shared  -o mex_demo.mex  mex_demo.o -L"c:\Program Files (x86)\Octave-3.6.1\lib\octave\3.6.1" -L"c:\Program Files (x86)\Octave-3.6.1\lib" -loctinterp -loctave -lcruft

A mex file is created however when I type mex_demo() inside octave I get the following warning

octave-3.6.4.exe:10> mex_demo() error: library open failed: c:\Users\david\Desktop\Work\flyby\mex_demo.mex

Any ideas?

Is it a problem with exporting symbols?

I had to remove -Wl,-export:mexFunction from the original ld invocation

ld -shared -o mex_demo.mex mex_demo.o -Wl,-export:mexFunction -L"c:\Program Files (x86)\Octave-3.6.1\lib\octave\3.6.1" -L"c:\Program Files (x86)\Octave-3.6.1\lib" -loctinterp -loctave -lcruft ld: unrecognized option '-Wl,-export:mexFunction' ld: use the --help option for usage information

g++ version is 4.6.2

Thanks

-David





reply via email to

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