Oct Files Help -- mkoctfile

View: New views
17 Messages — Rating Filter:   Alert me  

Oct Files Help -- mkoctfile

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I tried compiling the example code shown in the documentation for Oct files:

helloworld.cc
-----------------------------------------------------
     #include <octave/oct.h>

     DEFUN_DLD (helloworld, args, nargout,
       "Hello World Help String")
     {
       int nargin = args.length ();
       octave_stdout << "Hello World has " << nargin
             << " input arguments and "
             << nargout << " output arguments.\n";
       return octave_value_list ();
     }
-----------------------------------------------------

And I recieved the following error

octave.exe:14> mkoctfile helloworld.cc
'cl' is not recognized as an internal or external command,
operable program or batch file.
'link' is not recognized as an internal or external command,
operable program or batch file.


Does anyone know how to fix this or where I might start looking to fix this? I'm running windows xp. If there is more specific information you need, what is it?

Re: Oct Files Help -- mkoctfile

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

gOS wrote:
Does anyone know how to fix this or where I might start looking to fix this? I'm running windows xp. If there is more specific information you need, what is it?
After about an hour of web searching I found this little gem:
http://www.geocities.jp/tmoctwin/msvcoct.html

Now mkoctfile works. Perhaps there should be some note or link to this in the Octive doc that way windows users can get Octave to function fully. :/

Re: Oct Files Help -- mkoctfile

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


gOS wrote:
gOS wrote:
Does anyone know how to fix this or where I might start looking to fix this? I'm running windows xp. If there is more specific information you need, what is it?
After about an hour of web searching I found this little gem:
http://www.geocities.jp/tmoctwin/msvcoct.html

Now mkoctfile works. Perhaps there should be some note or link to this in the Octive doc that way windows users can get Octave to function fully. :/
I'm going to add this here since the creater of this home page seems to frequent this forum. I tried using clear so that I could recompile the file. Perhaps because I am specifically compiling mex files this isn't working. I still get:

octave:10> clear MexTest
octave:11> mkoctfile --mex MexTest.c
MexTest.c
LINK : fatal error LNK1104: cannot open file 'MexTest.mex'
octave:12>

Re: Oct Files Help -- mkoctfile

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  9-Jan-2008, gOS wrote:

| Now mkoctfile works. Perhaps there should be some note or link to this in
| the Octive doc that way windows users can get Octave to function fully. :/

It would be OK to add a note explaining that you need a compiler to
compile .oct and .mex files (though that does seem obvious).  But
since Octave is a GNU project, the manual will not be changed to
recommend non-free software.

jwe
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by Tatsuro MATSUOKA-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

You seem to use the MSVC-Octave.  As written in Readme.txt in MSVC-Octave, you need to install the
MSVC express edition (This is free edition.).
However, this information is not sufficient for almost all users.
So I wrote the guide to use the mkoctfile command in MSVC Octave.
Please visit my home page.

http://www.geocities.jp/tmoctwin/

And read the "Note for mkoctfile for MSVC-octave 3.0.0".

Regards
 
Tatsuro


--- gOS <bkirklin@...> wrote:

>
> I tried compiling the example code shown in the documentation for Oct files:
>
> helloworld.cc
> -----------------------------------------------------
>      #include <octave/oct.h>
>
>      DEFUN_DLD (helloworld, args, nargout,
>        "Hello World Help String")
>      {
>        int nargin = args.length ();
>        octave_stdout << "Hello World has " << nargin
>              << " input arguments and "
>              << nargout << " output arguments.\n";
>        return octave_value_list ();
>      }
> -----------------------------------------------------
>
> And I recieved the following error
>
> octave.exe:14> mkoctfile helloworld.cc
> 'cl' is not recognized as an internal or external command,
> operable program or batch file.
> 'link' is not recognized as an internal or external command,
> operable program or batch file.
>
>
> Does anyone know how to fix this or where I might start looking to fix this?
> I'm running windows xp. If there is more specific information you need, what
> is it?
> --
> View this message in context:
> http://www.nabble.com/Oct-Files-Help----mkoctfile-tp14713714p14713714.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>


--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by Tatsuro MATSUOKA-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

Oh! I missed this mail.
********************
octave:10> clear MexTest
octave:11> mkoctfile --mex MexTest.c
MexTest.c
LINK : fatal error LNK1104: cannot open file 'MexTest.mex'
octave:12>
*********************
I have not noticed it.

Hello Michael:
What I missed for the mex filed compiling?

Regards

Tatsuro

--- gOS <bkirklin@...> wrote:

>
>
> gOS wrote:
> >
> > Does anyone know how to fix this or where I might start looking to fix
> > this? I'm running windows xp. If there is more specific information you
> > need, what is it?
> >
>
> After about an hour of web searching I found this little gem:
> http://www.geocities.jp/tmoctwin/msvcoct.html
>
> Now mkoctfile works. Perhaps there should be some note or link to this in
> the Octive doc that way windows users can get Octave to function fully. :/
> --
> View this message in context:
> http://www.nabble.com/Oct-Files-Help----mkoctfile-tp14713714p14716520.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>


--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by Michael Goffioul-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 1/9/08, John W. Eaton <jwe@...> wrote:
> On  9-Jan-2008, gOS wrote:
>
> | Now mkoctfile works. Perhaps there should be some note or link to this in
> | the Octive doc that way windows users can get Octave to function fully. :/
>
> It would be OK to add a note explaining that you need a compiler to
> compile .oct and .mex files (though that does seem obvious).  But
> since Octave is a GNU project, the manual will not be changed to
> recommend non-free software.

Actually, the README file that is distributed with the binary packages
eplains briefly that you need MSVC compiler (and the Platform SDK)
in order to compile oct files (although the tutorial from Tatsuro is far
more complete). However, nobody reads the README files these
days... :-)

Michael.
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by Michael Goffioul-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 1/9/08, Tatsuro MATSUOKA <tmacchant@...> wrote:

> Hello
>
> Oh! I missed this mail.
> ********************
> octave:10> clear MexTest
> octave:11> mkoctfile --mex MexTest.c
> MexTest.c
> LINK : fatal error LNK1104: cannot open file 'MexTest.mex'
> octave:12>
> *********************
> I have not noticed it.
>
> Hello Michael:
> What I missed for the mex filed compiling?

I don't think you're missing anything. It's just that once a DLL is mapped
into memory by any process, the DLL is locked and you can't open it
for writing. As a consequence, the compiler cannot overwrite the mex
file (which is really a DLL). Normally, clearing MexTest should unmap
the mes file from memory, making it again available for writing, but
apparently it does not work. This might be a bug. John has probably a
better understanding of when a mex file is unloaded.

Michael.
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  9-Jan-2008, Michael Goffioul wrote:

| I don't think you're missing anything. It's just that once a DLL is mapped
| into memory by any process, the DLL is locked and you can't open it
| for writing. As a consequence, the compiler cannot overwrite the mex
| file (which is really a DLL). Normally, clearing MexTest should unmap
| the mes file from memory, making it again available for writing, but
| apparently it does not work. This might be a bug. John has probably a
| better understanding of when a mex file is unloaded.

I seem to recall that with the old symbol table code (what is in 3.0)
mex files were unloaded properly when they were cleared.  I intended
to look at the problem before releasing 3.0, but maybe that was
something that slipped by.  Anyway, if it is still true that they are
not properly unloaded, I don't have any plans to fix it for any 3.0.x
release.

I also though it was fixed now in cvs head, but that doesn't appear to
be the case.  Clearing .oct files does seem to unload them.  I don't
know recall now why mex files are not handled in the same way, at
least with the new symbol table code.

jwe
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by Tatsuro MATSUOKA-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear gOS

> octave:10> clear MexTest
> octave:11> mkoctfile --mex MexTest.c
> MexTest.c
> LINK : fatal error LNK1104: cannot open file 'MexTest.mex'
> octave:12>

Please try

octave> clear MexTest
octave> system('cmd');
Cmdprompt> mkoctfile -verbode --mex MexTest.c

and report results.

Regards

Tatsuro


 


--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by Tatsuro MATSUOKA-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello John

--- gOS <bkirklin@...> wrote:
> Perhaps there should be some note or link to this in
> the Octive doc that way windows users can get Octave to function fully. :/
*********************

My page is private but officailly I am revising the page
http://wiki.octave.org/wiki.pl?OctaveForWindows.

This page has a note to this topic and a link to my page.

Then I propose that OctaveForWindows ans OctaveForMac in the CategoryInstall in the Octave Wiki will
be cited in the download page of Octve.

Unfortunately other pages in the CategoryInstall are obsolate.  
I hope someone to revise them.

Regards

Tatsuro

 

--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by Tatsuro MATSUOKA-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

This is just an error correction.  Sorry for my carelessness.

+++++++++++++
Please try
 
octave> clear MexTest
octave> system('cmd');
Cmdprompt> mkoctfile --verbose --mex MexTest.c #Here is modified
 
and report results.
+++++++++++++++++++

Regards
Tatsuro


--- Tatsuro MATSUOKA <tmacchant@...> wrote:

> Dear gOS
>
> > octave:10> clear MexTest
> > octave:11> mkoctfile --mex MexTest.c
> > MexTest.c
> > LINK : fatal error LNK1104: cannot open file 'MexTest.mex'
> > octave:12>
>
> Please try
>
> octave> clear MexTest
> octave> system('cmd');
> Cmdprompt> mkoctfile -verbode --mex MexTest.c
>
> and report results.
>
> Regards
>
> Tatsuro
>
>
>  
>
>
> --------------------------------------
> Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
> http://pr.mail.yahoo.co.jp/toolbar/
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>


--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tatsuro MATSUOKA-2 wrote:
Hello

This is just an error correction.  Sorry for my carelessness.

+++++++++++++
Please try
 
octave> clear MexTest
octave> system('cmd');
Cmdprompt> mkoctfile --verbose --mex MexTest.c #Here is modified
 
and report results.
+++++++++++++++++++

Regards
Tatsuro


--- Tatsuro MATSUOKA <tmacchant@yahoo.co.jp> wrote:

> Dear gOS
>
> > octave:10> clear MexTest
> > octave:11> mkoctfile --mex MexTest.c
> > MexTest.c
> > LINK : fatal error LNK1104: cannot open file 'MexTest.mex'
> > octave:12>
>
> Please try
>
> octave> clear MexTest
> octave> system('cmd');
> Cmdprompt> mkoctfile -verbode --mex MexTest.c
>
> and report results.
>
> Regards
>
> Tatsuro
>
>
>  
>
>
> --------------------------------------
> Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
> http://pr.mail.yahoo.co.jp/toolbar/
> _______________________________________________
> Help-octave mailing list
> Help-octave@octave.org
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>


--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/
_______________________________________________
Help-octave mailing list
Help-octave@octave.org
https://www.cae.wisc.edu/mailman/listinfo/help-octave
Tatsuro,

This had no effect, and as JWE pointed out it seems to not work in Linux Octave either, so I'm just going to run a Batch file an close down octave every time I want to compile a mex file. Oh well, at least I can compile things.

Thanks.

=============

Anyone Else,

Is there a listing of what mex functions are supported in Octave 3.0? I've checked the Doc and now found any. The reason I'm asking is that I'm trying to figure out if I am calling mxCalcSingleSubscript incorrectly for your mex compiler. It does not throw an error, but it returns an incorrect index which does not move beyond the first row of the file I'm trying to turn into a Cell Array.

Here is a code sample if it helps:

=========================================

    // ** INITIALIZATIONS NOT SHOWN

    cell_dims[0] = numberOfRows;
    cell_dims[1] = numberOfColumns;
   
    plhs[0] = mxCreateCellArray(2,cell_dims);
    nsubs=mxGetNumberOfDimensions(plhs[0]);
    subs=mxCalloc(2,sizeof(int));
       
    for(i = 0; i < numberOfRows; i++) {
      line = lines[i]; // Grab next line of file
      token = (char*)strtok(line," ,"); // Grab first entry with Delimiter
      for(j = 0; j < numberOfColumns; j++) {
        charArr = mxCreateString(token);
        subs[0] = i;
        subs[1] = j;

        // **** OFFENDING LINE ***** Does not throw error, but returns incorrect index
        // ie(0,0:j-1) Never moves beyond first row.
        index = mxCalcSingleSubscript(plhs[0],nsubs,subs);        

        mexPrintf("J = %d, Index = %d: %s\n",j,index,token); // Print Statement verifying bug

        // **** CRUX POINT **** mxSetCell does not set the correct cell because index is wrong
        mxSetCell(plhs[0],index,charArr);
        if(j != numberOfColumns) {
          token = (char *)strtok(NULL," ,");
        }
      }      
    }

====================================================


Re: Oct Files Help -- mkoctfile

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10-Jan-2008, gOS wrote:

| Is there a listing of what mex functions are supported in Octave 3.0? I've
| checked the Doc and now found any.

Look at mex.h and the mexproto.h file that it includes.

If you think this belongs in the Octave manual, please consider
contributing a patch for that.

| The reason I'm asking is that I'm trying
| to figure out if I am calling mxCalcSingleSubscript incorrectly for your mex
| compiler. It does not throw an error, but it returns an incorrect index
| which does not move beyond the first row of the file I'm trying to turn into
| a Cell Array.

If you think you've found a bug in Octave, please submit a complete
report to the bug@... mailing list that includes enough
information to easily reproduce the problem.  In this case, your code
sample might help, but it would be much more helpful if you could come
up with a simple, complete test case that can be compiled and that
demonstrates the problem.  That would save some time for someone who
might be able to fix the problem.

jwe
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Oct Files Help -- mkoctfile

by gOS :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John W. Eaton wrote:
If you think you've found a bug in Octave, please submit a complete
report to the bug@octave.org mailing list that includes enough
information to easily reproduce the problem.  In this case, your code
sample might help, but it would be much more helpful if you could come
up with a simple, complete test case that can be compiled and that
demonstrates the problem.  That would save some time for someone who
might be able to fix the problem.

jwe
I did find that site you linked me too, but it gave no details on the implementation past what it took as arguments.

Its unfortunate, but I'm at work so I can't really do more than solve the problem that I need to get my file working. Additionally, I have been unable to get octave mex files to work on my home computer, so any exploration of the actual bug, I don't have time for, nor do I have time to replicate the error in a simpler file.

However, I wrote another method that does what this should do, and it is fairly simple, though it takes different parameters. The only thing I can imagine is that the calculation is somehow wrong in the mx function that wasn't working, and as I said, I am unable to explore the problem with my recourses and commitments.

I was able to move past this method by using my own method:

int calcIndex(int rows, int row, int col) {
  return rows * col + row;
}

I post here in the hopes that it does help whoever should want to use this in the future if the bug doesn't get fixed. Unfortunately, I can't dedicate any more time to the problem, but it does look as if it's a bug.

My thanks to those who can, and my apologies for being unhelpful,
gOS

Re: Oct Files Help -- mkoctfile

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10-Jan-2008, gOS wrote:

| to figure out if I am calling mxCalcSingleSubscript incorrectly for your mex
| compiler. It does not throw an error, but it returns an incorrect index
| which does not move beyond the first row of the file I'm trying to turn into
| a Cell Array.
|
| Here is a code sample if it helps:
|
| [...]

I checked in the following change to cvs head and the 3.0 branch.  I
think mxCalcSingleSubscript should work correctly with this patch.

jwe



src/ChangeLog:

2008-01-10  John W. Eaton  <jwe@...>

        * mex.cc (calc_single_subscript_internal): New static function.
        (mxArray_octave_value::calc_single_subscript): Use it.
        (mxArray_matlab::calc_single_subscript): Use it.


Index: src/mex.cc
===================================================================
RCS file: /cvs/octave/src/mex.cc,v
retrieving revision 1.36
diff -u -u -r1.36 mex.cc
--- src/mex.cc 28 Dec 2007 20:56:57 -0000 1.36
+++ src/mex.cc 10 Jan 2008 19:27:17 -0000
@@ -271,6 +271,38 @@
   }
 };
 
+static mwIndex
+calc_single_subscript_internal (mwSize ndims, const mwSize *dims,
+ mwSize nsubs, const mwIndex *subs)
+{
+  mwIndex retval = 0;
+
+  switch (nsubs)
+    {
+    case 0:
+      break;
+
+    case 1:
+      retval = subs[0];
+      break;
+
+    default:
+      {
+ // Both nsubs and ndims should be at least 2 here.
+
+ mwSize n = nsubs <= ndims ? nsubs : ndims;
+
+ retval = subs[--n];
+
+ while (--n >= 0)
+  retval = dims[n] * retval + subs[n];
+      }
+      break;
+    }
+
+  return retval;
+}
+
 // The object that handles values pass to MEX files from Octave.  Some
 // methods in this class may set mutate_flag to TRUE to tell the
 // mxArray class to convert to the Matlab-style representation and
@@ -605,17 +637,10 @@
 
   mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const
   {
-    mwIndex retval = 0;
-
     // Force ndims, dims to be cached.
     get_dimensions ();
 
-    mwIndex n = nsubs <= ndims ? nsubs : ndims;
-
-    while (--n > 0)
-      retval = retval * dims[n] + subs[n];
-
-    return retval;
+    return calc_single_subscript_internal (ndims, dims, nsubs, subs);
   }
 
   size_t get_element_size (void) const
@@ -996,14 +1021,7 @@
 
   mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const
   {
-    mwIndex retval = 0;
-
-    mwSize n = nsubs <= ndims ? nsubs : ndims;
-
-    while (--n > 0)
-      retval = retval * dims[n] + subs[n];
-
-    return retval;
+    return calc_single_subscript_internal (ndims, dims, nsubs, subs);
   }
 
   size_t get_element_size (void) const

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Propasal to the download page Re: Oct Files Help -- mkoctfile

by Tatsuro MATSUOKA-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello John

I proposed the below.
Please give me reply whether you will accept or not.

Regards

Tatsuro

--- Tatsuro MATSUOKA <tmacchant@...> wrote:

> Hello John
>
> --- gOS <bkirklin@...> wrote:
> > Perhaps there should be some note or link to this in
> > the Octive doc that way windows users can get Octave to function fully. :/
> *********************
>
> My page is private but officailly I am revising the page
> http://wiki.octave.org/wiki.pl?OctaveForWindows.
>
> This page has a note to this topic and a link to my page.
>
> Then I propose that OctaveForWindows ans OctaveForMac in the CategoryInstall in the Octave Wiki
> will
> be cited in the download page of Octve.
>
> Unfortunately other pages in the CategoryInstall are obsolate.  
> I hope someone to revise them.
>
> Regards
>
> Tatsuro
>
>  
>
> --------------------------------------
> Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
> http://pr.mail.yahoo.co.jp/toolbar/
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>


--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave