|
From: Lee D. <le...@ea...> - 2007-05-24 19:24:05
|
Hans-Bernhard Bröker wrote:
> Lee Duke wrote:
>> I'm trying to access gnuplot from within C++. I'd like to be able to
>> pass standard commands to the gnuplot interface and get plots that I
>> can either view, save to a file, or print. Is there a reasonably easy
>> and painless way to do this in some platform-independent way?
>
> There cannot be a truly platform-independent way of doing that,
> because platform dependence sets in before you can even run an
> external program, much less redirect its inputs or outputs.
>
> As portable as it gets is what N. Devilla's C interfacing library
> supports. That should be usable from C++, too.
>
Thanks, Hans.
Actually, I found what I was looking for "plplot-config"
Using that I can set up my configure.in file:
PLPLOTCONFIG=plplot-config
AC_ARG_WITH(plplot-config,
[[ --with-plplot-config="" Use the given path to plplot-config
when determining
plplot configuration; defaults to
"plplot-config"]],
[
if test "$withval" != "yes" -a "$withval" != ""; then
PLPLOTCONFIG=$withval
fi
])
plplotversion=0
AC_DEFUN([PLPLOTTEST],
[
AC_REQUIRE([AC_PROG_AWK])
AC_MSG_CHECKING([plplot version])
if plplotversion=`$PLPLOTCONFIG --version`; then
AC_MSG_RESULT([$plplotversion])
else
AC_MSG_RESULT([not found])
AC_MSG_ERROR([plplot is required. Try --with-plplot-config.])
fi])
# Call PLPLOTTEST func
PLPLOTTEST
# Verify minimus requires
vers=`echo $plplotversion | $AWK 'BEGIN { FS = "."; } { printf "%
d", ($1 * 1000 + $2) * 1000 + $3;}'`
if test -n "$vers" && test "$vers" -ge 5006001; then
PLPLOT_CPPFLAGS="`$PLPLOTCONFIG --cflags`"
PLPLOT_CXXFLAGS="`$PLPLOTCONFIG --cflags`"
PLPLOT_LIBS="`$PLPLOTCONFIG --libs --with-c++`"
else
AC_MSG_ERROR([plplot 5.6.1 or newer is required])
fi
AC_SUBST(PLPLOT_LIBS)
CPPFLAGS="$CPPFLAGS $PLPLOT_CPPFLAGS"
CXXFLAGS="$CXXFLAGS $PLPLOT_CXXFLAGS"
Then in my "Makefile.am" file I add:
myprogramname_LDDFLAGS = $(PLPLOT_LIBS)
And then I have a platform independent configuration. After running
autoscan
aclocal
automake
autoconf
./configure
make
I am in business.
|