[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
linking
From: |
Andy Buckle |
Subject: |
linking |
Date: |
Wed, 7 Apr 2010 21:51:47 +0100 |
I have had trouble trying to link. I have made a simple example that
illustrates the problem, and my ugly solution. Is is possible to avoid
the system call to ar? (All files in the same directory).
file: b.h
double b_fn(double in);
file: b.cpp
#include "b.h"
double b_fn(double in) {
return in*in;
}
file: a.cpp
#include <octave/oct.h>
#include "b.h"
DEFUN_DLD (a, args, nargout,
"no help available for this test fn") {
if (args.length() != 1) {
error("a: there must be 1 arg");
return octave_value_list();
}
double in=args(0).double_value();
double out=b_fn(in);
return octave_value(out);
}
file: compile.m
clear a b
delete *.o
delete *.oct
delete *.a
mkoctfile -c a.cpp
mkoctfile -c b.cpp
system('ar cr libb.a b.o')
mkoctfile -L. -lb a.o
--
/* andy buckle */