[Top][All Lists]

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

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

From: Douglas Eck
Subject: FYI: Compiling stand alone programs, another example....
Date: Thu, 18 Oct 2001 14:16:31 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20010913

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.

Doug Eck

Source Code:
#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++) {
  cout << "Hello world! " << endl;
  cout << m;

##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
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)

        $(CC) -c $(OPTIMIZATION) -o helloWorld.o $(CCINCLUDES)

        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]