From help-octave-request at bevo dot che dot wisc dot edu Tue Feb 19 02:46:53 2002 Subject: Re: Linking C++ classes in non-octave applications [liboctave] From: Douglas Eck To: "Jan D'hooge" CC: help-octave at bevo dot che dot wisc dot edu Date: Tue, 19 Feb 2002 09:45:15 +0100 This is a multi-part message in MIME format. --------------020805020901060004090101 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Hi Jan, This is not so hard to do. The challenge is in making sure you link to the appropriate libs when you compile your application. As of octave-2.1.35 you need to link to quite a few libs. However, John Eaton said in a posting some time back that this will be simplified quite a bit in 2.1.36. Once you can compile a simple liboctave app, you are free to link to other libraries. I for example have linked a liboctave-linked app to some MIDI libs that are themselves linked dynamically against libqt. And everything worked out. Let me say that it's a quite nice environment to work in. You have access to all of the octave data structures. Also, you have the ability to call your program from the octave interpreter, making it easy to pass in and write out data to disk via .mat files. And with a standalone app you can use easily use gdb and gprof! I included a Makefile and helloWorld.cc which compiles on my debian box. Your mileage may vary depending on how octave was compiled. Also, if you're using windows, then please let me know if you have success. I haven't been able to get a standalone app to compile on windows (cygwin). Finally, a special note on kpathsea. As of now, octave uses a modified kpathsea. This means that you must have the libkpathsea from the octave sources! You'll see in my Makefile that I add /usr/src/octave-2.1.35/kpathsea to the library path. Hopefully upstream changes will be made to kpathsea so that this is no longer necessary... but I'm not clear on the status of this right now. Cheers, Doug Jan D'hooge wrote: > Hi, > > I'm new to the octave source code but I thought of using (part of) it as > a basic vector/matrix/arrays C++ library. I compiled the Octave > libraries without too much problem but linking them with my own > applications doesn't seem soo straight forward. > > Has anyone ever tried to create this kind of library from the Octave > classes? Wouldn't it a good idea to do so? There aren't any good, free > algebra libraries available from the net to my knowledge. Of course, I > wouldn't mind doing this (as I need them myself) but some additional > documentation on the C++ classes would be practical. Is more available > on the structure of the classes and how they inter-relate? > > > Thanks, > > Jan. > > > > ------------------------------------------------------------- > 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 > ------------------------------------------------------------- > > -- Dr. Douglas Eck, http://www.idsia.ch/~doug Istituto Dalle Molle di Studi sull'Intelligenza Artificiale (IDSIA) Neural Networks, Rhythm Perception and Production, Dynamical Systems --------------020805020901060004090101 Content-Type: text/x-c++src; name="helloWorld.cc" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="helloWorld.cc" //Douglas Eck doug at idsia dot ch #include int main(void) { int sz=20; Matrix m = Matrix(sz,sz); for (int r=0;r