[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.
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
-------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: Compiling stand alone programs, another example....,
Douglas Eck <=