help-octave
[Top][All Lists]
Advanced

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

Re: Running C++ program from octave ??


From: Robert A. Macy
Subject: Re: Running C++ program from octave ??
Date: Fri, 22 Jul 2005 08:20:45 -0700

Henry,

I accidentally put the wrong Cc: on that last email. Thanks
for catching it at your end.  

As I said, I have mkoctfile 2.1.50 the equivalent to your
file?  Here are the top lines...
#! /bin/sh
#
# mkoctfile -- create a .oct file suitable for dynamic
linking by
# Octave.

# Exit immediately on any error.

set -e

# Default values for these variables are filled in when
Octave is
# compiled. 

: ${SED="/usr/bin/sed"}

: ${CPPFLAGS=""}
....and so on.

It's just this program does nothing.  

I think the problem is that the binary version 2.1.50 does
NOT have a single .c .cc or .h file in it.  Since no
headers, no way possible to make a single .oct file.  I
remember seeing in the older versions of octave matching
sets of files ending in .c  Like audio.m  and an audio.c
and .h's

However, I lost earlier versions of octave when HD crashed.
 Just spent an hour at the octave.org website and couldn't
find any source code for the 2.1.50 version I have.  Any
idea where to find the complete packages and source code
for 2.1.50?  

              - Robert -

On Thu, 21 Jul 2005 19:52:48 -0700
 "Henry F. Mollet" <address@hidden> wrote:
> address@hidden
> Hi Robert, (off-list)
> I noticed that a copy would have gone to a different
> list. Looks to me that
> you now need a "Windows Wizard" to help you find your
> mkoctfile 2.1.50 file.
> Perhaps you should re-post on octave help-list. I could
> barely get it to run
> on my Mac.
> Cheers, Henry
> N.B. Below is oregonator.cc. I would have attached it but
> I cannot because
> my mail program cannot get to it. Save the text as
> oregonator.cc and see if
> your mkoctfile utiltity will create the .o and the .oct
> files. To run it use
> oregonator ([1,2,3],0) at the octave prompt and the
> answer should be (77.27;
> - 0.013; - 0.322).
> 
> #include <octave/oct.h>
> 
> DEFUN_DLD (oregonator, args, ,
>   "The `oregonator'.\n\
> \n\
> Reference:\n\
> \n\
>   Oscillations in chemical systems.  IV.  Limit cycle
> behavior in a\n\
>   model of a real chemical reaction. Richard J. Field and
> Richard\n\
>   M. Noyes, The Journal of Chemical Physics, Volume 60
> Number 5,\n\
>   March 1974.")
> {
>   ColumnVector dx (3);
> 
>   ColumnVector x (args(0).vector_value ());
> 
>   dx(0) = 77.27 * (x(1) - x(0)*x(1) + x(0) -
> 8.375e-06*pow (x(0), 2.0));
>   dx(1) = (x(2) - x(0)*x(1) - x(1)) / 77.27;
>   dx(2) = 0.161*(x(0) - x(2));
> 
>   return octave_value (dx);
> }
> #************
> [~] -bash-2.05b 504$ cd /usr/local/share/octave/examples/
> [/usr/local/share/octave/examples] -bash-2.05b 505$ ls
> hideoregonator.m        oregonator.o
> oregonator.cc           oregonator.oct
> [/usr/local/share/octave/examples] -bash-2.05b 506$
> octave
> GNU Octave, version 2.1.71 (powerpc-apple-darwin8.1.0).
> 
> octave:1> oregonator ([1,2,3],0)
> ans =
> 
>    77.269353
>    -0.012942
>    -0.322000
> **************
> 
> 
> 
> on 7/21/05 7:23 PM, Robert A. Macy at address@hidden
> wrote:
> 
> > mkoctfile.link is 34 bytes
> > 
> > mkoctfile.lin or, mkoctfile.lnk,
> > around 112 bytes representing "shortcut" to
> > mkoctfile 2.1.50
> >   around 9,710 bytes
> > looks like compile instructions.
> > 
> > I put a very simple file called
> > testoctave.cpp 
> > containing a C++ program just for this test
> > 
> > typing mkoctfile 2.1.50  testoctave.cpp
> > or mkoctfile 2.1.50 testoctave
> > or mkoctfile  testoctave.cpp
> > or mkoctfile testoctave
> > 
> > in *any* of the folders of
> >  octave 
> >  GNU octave 2.1.50\
> >   ..\bin 
> >   ..\octave_files
> > 
> > all do nothing but give this error message...
> > Bad command or file name
> > 
> >             - Robert -
> > 
> > 
> > 
> > On Thu, 21 Jul 2005 18:45:07 -0700
> >  "Henry F. Mollet" <address@hidden> wrote:
> >> [/usr/local/bin] -bash-2.05b 510$ ls -l
> >> total 13864
> >> lrwxr-xr-x   1 root  wheel       16 Jun 29 10:16
> >> mkoctfile ->
> >> mkoctfile-2.1.71
> >> -rwxr-xr-x   1 root  wheel    10332 Jun 29 10:16
> >> mkoctfile-2.1.71
> >> 
> >> As you can see from above, mkoctfile (only 16 kb) is
> an
> >> alias (=shortcut) to
> >> the *utility* mkoctfile-2.1.71 (10332 kB). This
> utility
> >> is making (mk) an
> >> .oct file from a .cc source file. To use it one has to
> >> supply the name of a
> >> C or C++ source file (.cc).
> >> 
> >> You say that you're using GNU octave 2.1.50, therefore
> >> the mkoctfile utility
> >> on you machine cannot be mkoctfile-2.1.71. I would
> expect
> >> it to be
> >> mkoctfile-2.1.50. Using mkoctfile (the alias) should
> tell
> >> you machine to use
> >> the utility that you actually have on you machine. I
> >> don't know what
> >> mkoctfile.lnk and mkoctfile.link are, presumably links
> to
> >> the utility to
> >> make an .oct file on your machine. You probably could
> use
> >> either one but
> >> probably not mkoctfile. In any case you have to
> provide a
> >> source file (.cc)
> >> so the utility can get to work.
> >> 
> >> Yes, at the DOS-prompt which is the same as the
> Terminal
> >> window on a Mac
> >> with OS X. The good old days are gone on a Mac when I
> did
> >> not have to worry
> >> about any prompts. It was the main reason I used a
> Mac.
> >> Now, if you want to
> >> get real work done on a Mac with OS X, you have to use
> >> the Terminal Window.
> >> For example, as per recent discussion, Spotlight is
> >> useless for finding
> >> files in /usr. The Unix utility locate does the trick
> in
> >> a fraction of
> >> second once the database has been created.
> >> Henry.
> >> 
> >> 
> >> 
> >> on 7/21/05 3:43 PM, Robert A. Macy at
> address@hidden
> >> wrote:
> >> 
> >>> Henry,  
> >>> 
> >>> I have three files named mkoctfile...
> >>> 
> >>> mkoctfile.lnk . . . . this is a shortcut on the WinXP
> >>>     or, mkoctfile.lin . . on the Win98
> >>> mkoctfile.link . . . . text file?
> >>> mkoctfile-2.1.71 . . . . this is a text file?
> >>>  appears to have all the compile statements in it
> >>> 
> >>> Using command line prompt (not octave, but DOS)
> >>> mkoctfile generates the standard error message
> >>>   Bad command or file name
> >>> no matter where typed.
> >>>  GNU octave 2.1.50
> >>>    ../bin
> >>>    ../octave_files
> >>> 
> >>> Can't get passed that point.
> >>> 
> >>>              - Robert -
> >>> 
> >>> On Thu, 21 Jul 2005 11:59:29 -0700
> >>>  "Henry F. Mollet" <address@hidden> wrote:
> >>>> Required to be able to run dynamically linked
> >> functions.
> >>>> 
> >>>> It is a two step process. First the .cc source file
> >> needs
> >>>> to be compiled
> >>>> using 'mkoctfile filename' at the shell prompt (not
> >> the
> >>>> octave prompt) so
> >>>> this requires mkoctfile. Second the Octave version
> has
> >> to
> >>>> be able to run the
> >>>> .oct file which requires octave_config_info ("dld")
> =
> >> 1,
> >>>> not 0.
> >>>> 
> >>>> After compilation one has the files filename.cc,
> >>>> filename.o, and the
> >>>> filename.oct. Using 'filename' at the octave prompt
> >> will
> >>>> use the
> >>>> filename.oct. 
> >>>> 
> >>>> Now assume you also have a corresponding filename.m.
> >> This
> >>>> one was running
> >>>> too slowly for you and you wanted to speed it up.
> You
> >>>> therefore created a
> >>>> .cc source using C or C++ language and then you
> >> compiled
> >>>> it. Now in addition
> >>>> to the .oct file you also have the .m file in the
> same
> >>>> directory. I believe
> >>>> octave will use the .oct file rather than the .m
> file
> >> if
> >>>> you type 'filename'
> >>>> at the octave prompt. One can test this by
> temporarily
> >>>> renaming on of the
> >>>> files, so that Octave can no longer find it when
> >> called
> >>>> with the old name.
> >>>> Henry
> >>>> N.B On my new Octave 2.1.71 installation I could not
> >> find
> >>>> the oregonator.cc
> >>>> nor orgegonator.m examples, so I grabbed the ones on
> >> my
> >>>> old computer and am
> >>>> now testing what I said in previous paragraph.
> >>>> [/usr/local/share/octave/examples] -bash-2.05b 518$
> ls
> >>>> oregonator.cc   oregonator.m
> >>>> 
> >>>> [/usr/local/share/octave/examples] -bash-2.05b 522$
> >> sudo
> >>>> mkoctfile
> >>>> oregonator.cc
> >>>> % sudo because all my directories are locked and I
> >> don't
> >>>> know how to obtain
> >>>> root privilages for all directories and files in one
> >>>> sweep.
> >>>> Cut
> >>>> 
> >>>> [/usr/local/share/octave/examples] -bash-2.05b 523$
> ls
> >>>> oregonator.cc   oregonator.m    oregonator.o
> >>>>    oregonator.oct
> >>>> 
> >> 
> >> 
> > 
> 
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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