help-octave
[Top][All Lists]
Advanced

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

FYI: Compiling stand alone programs, another example....


From: John W. Eaton
Subject: FYI: Compiling stand alone programs, another example....
Date: Thu, 8 Nov 2001 23:46:44 -0600

On 18-Oct-2001, Douglas Eck <address@hidden> wrote:

| I am able to compile a stand-alone program linked against liboctave.
| I did it on a debian "sid" box.
| 
| For future reference, here is the makefile and the program code.
| It is similar to other examples on this list, but I found I needed
| a couple of different libraries. Note as well that I needed
| kpathsea from Octave. I believe this has been mentioned before.

In 2.1.36 (or the current CVS sources, if you want it now) you won't
need to link to the readline and kpathsearch libraries if all you want
is numerical stuff from liboctave.

I don't think you need the hdf5 library now, even if you configured
and compiled Octave to use that library, since it is only used in
load-save.cc (part of the interpreter) and not referenced by anything
in liboctave.

jwe

| Regards,
| Doug Eck
| 
| 
| Source Code:
| -------------------SNIP----------------------------
| #include <octave/oct.h>
| int main(void) {
|    int sz=20;
|    Matrix m = Matrix(sz,sz);
|    for (int r=0;r<sz;r++) {
|      for (int c=0;c<sz;c++) {
|        m(r,c)=r*c;
|      }
|    }
|    cout << "Hello world! " << endl;
|    cout << m;
| }
| 
| Makefile:
| --------------------SNIP---------------------------
| ##Primitive but effective
| ##Thanks to Paul Kinzele for mkoctver.sh and the Makefile
| ##I used as an example to generate this one.
| ##
| ##Douglas Eck address@hidden
| 
| ##If you don't want debugging and profiling
| ##OPTIMIZATION = -O2
| ##If you want debugging and profiling
| OPTIMIZATION = -pg -g
| ##You can use Paul Kinzele's mkoctver to get the octave version if you
| ##want. I took that out for simplicity here.
| OCTAVE_VERSION=2.1.34
| MKOCTFILE = mkoctfile -v
| CC=g++
| CCINCLUDES=-I/usr/include/octave-$(OCTAVE_VERSION) 
-I/usr/include/octave-$(OCTAVE_VERSION)/octave
| LD_LIBS=-lblas -loctave -loctinterp -ldl  -lcruft  -lg2c -ltermcap -lhdf5 
-lreadline -lkpathsea
| LD_PATHS=-L/usr/lib/octave-2.1.34 -L/usr/src/octave-2.1.34/kpathsea
| 
| helloWorld: helloWorld.o
|       $(CC) $(OPTIMIZATION) helloWorld.o -o helloWorld $(LD_PATHS) $(LD_LIBS)
| 
| helloWorld.o: helloWorld.cc
|       $(CC) -c $(OPTIMIZATION) helloWorld.cc -o helloWorld.o $(CCINCLUDES)
| 
| clean:
|       rm helloWorld.o helloWorld



-------------------------------------------------------------
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]