help-octave
[Top][All Lists]
Advanced

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

Re: New User and how to use octave in c code ?


From: Mike Miller
Subject: Re: New User and how to use octave in c code ?
Date: Thu, 27 Apr 2017 07:14:06 -0700
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Apr 26, 2017 at 10:43:00 -0700, Progressive wrote:
> CXX = g++
> CXXFLAGS = -g -Wall `root-config --cflags --libs` -fPIC -O3
> 
> LD = g++
> LDFLAGS = -g
> 
> SOURCES=$(wildcard *.cpp)
> OBJECTS=$(SOURCES:.cpp=.o)
> HEADERS=$(SOURCES:.cpp=.h)
> EXECUTABLE=test_octave
> 
> CXXFLAGS += $(shell root-config --cflags)
> LIBS = $(shell root-config --libs)
> NGLIBS = $(shell root-config --glibs)
> GLIBS = $(filter-out -lNew, $(NGLIBS))
> 
> 
> .SUFFIXES: .cpp
> 
> # ==========================================
> all: $(SOURCES) $(EXECUTABLE)
> 
> $(EXECUTABLE): $(OBJECTS)
>       $(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(LIBS) 
> 
> .cpp.o: $(SOURCES) $(HEADERS)
>       $(CXX) -c $(CXXFLAGS) $< -o $@ -I$(PWD) 
> 
> clean:
>       rm -f $(EXECUTABLE) *.o 
> 
> 
> 
> That's a good question. I have a .cpp file (Filter.cxx) written to use Cern
> ROOT: (attached) Filter.cxx
> <http://octave.1599824.n4.nabble.com/file/n4683049/Filter.cxx>   to analyze
> data (Filter_trace_array.root) which is generated by another macro. The data
> is stored as a root file:  Filter_traces_array.root
> <http://octave.1599824.n4.nabble.com/file/n4683049/Filter_traces_array.root> 
> . 
> In Filter.cxx I would like to implement octave. At the moment I only tried
> to compile it successfully by including the octave header. But after a lot
> of try and error I'm convinced that this is not possible?

The easiest approach to try would be to use mkoctfile as the compiler
and linker in the makefile that you have shown here. Simply change

    CXX = g++

to

    CXX = mkoctfile

and add --link-stand-alone to the $(EXECUTABLE) rule.

The purpose of mkoctfile is to act as a wrapper for the compiler and
linker, adding the appropriate options to build against Octave's
libraries. Most of the same options you would normally pass to gcc can
be passed to mkoctfile.

On Thu, Apr 27, 2017 at 05:56:35 -0700, Progressive wrote:
> Is there somewhere an official forum for octave ?

Yes, you're using it.

-- 
mike



reply via email to

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