[Top][All Lists]

[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 (part of the interpreter) and not referenced by anything
in liboctave.


| 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 and the Makefile
| ##I used as an example to generate this one.
| ##
| ##Douglas Eck address@hidden
| ##If you don't want debugging and profiling
| ##If you want debugging and profiling
| ##You can use Paul Kinzele's mkoctver to get the octave version if you
| ##want. I took that out for simplicity here.
| MKOCTFILE = mkoctfile -v
| CC=g++
| CCINCLUDES=-I/usr/include/octave-$(OCTAVE_VERSION) 
| 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:
|       $(CC) -c $(OPTIMIZATION) -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:
How to fund new projects:
Subscription information:

reply via email to

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