Graphics libraries under X on Linux using g++-2.7.0

Graphics libraries under X on Linux using g++-2.7.0

Post by Mark Edward Johnsto » Wed, 30 Aug 1995 04:00:00



I have various C++ programs which generate numerical output,
and I would like to be able to see a visualisation of this
output on the screen as my programs run.

I have done such things previously under DOS using the graphics
routines which came with Turbo C++, but I would like
to know the best way to do it under X-windows.

I am using g++-2.7.0 on a 486 running Linux.

The Slackware distribution
(which I installed) included the InterViews 3.1 class libraries.
Would these be an appropriate tool ?  
I was unable to get a simple example program from the manual to
link - it gave me 'undefined reference' errors. Does anybody
know how to setup InterViews on Linux correctly so that it finds
the relevant libraries and include files ?

Any advice/information/abuse would be most welcome.

Mark Johnston.


 
 
 

Graphics libraries under X on Linux using g++-2.7.0

Post by Jan Reime » Thu, 31 Aug 1995 04:00:00



Quote:>I have various C++ programs which generate numerical output,
>and I would like to be able to see a visualisation of this
>output on the screen as my programs run.

>I have done such things previously under DOS using the graphics
>routines which came with Turbo C++, but I would like

been there, done that

Quote:>to know the best way to do it under X-windows.

>I am using g++-2.7.0 on a 486 running Linux.

Identical to my current system.

Quote:

>The Slackware distribution
>(which I installed) included the InterViews 3.1 class libraries.
>Would these be an appropriate tool ?  

More complicated than my solution below.

Quote:>I was unable to get a simple example program from the manual to
>link - it gave me 'undefined reference' errors. Does anybody
>know how to setup InterViews on Linux correctly so that it finds
>the relevant libraries and include files ?

Not me.

Quick answer:  Open a pipe to gnuplot.

1) write your data to a temp file.
2) open a pipe to gnuplot, From memory:

opfstream plotpipe("|gnuplot");
plotpipe << "plot '" << tempFileName <<"'" << endl;

3) Send replot commands to the pipe each time the data is updated.

Classes with data you want to plot, can be derived from an interface
class Plotable which has a DumpData()=0; member function which returns
"String" containing the temp file name.  Then make a Plotter class
which opens the pipe and sends appropriate commands to gnuplot.
Each instance of Plotter opens another gnuplot window.  So you can
have numerous plots of different data being updated live.  It looks
very impressive and all you have to do is learn some simple gnuplot
commands.  No wheel re-invension nessecary!

Plotter and Plotable should be re-usable in many applications.

I don't know how experienced you are with unix, so if you need more
details let me know.

--
 +--------------------------------------+-------------------------------------+
 | Jan N. Reimers,  Research Scientist  | Sorry, Don't have time to write the |
 | Moli Energy (1990) Ltd. B.C. Canada  | usual clever stuff in this spot.    |


 
 
 

1. libg++-2.7.0a linkage under linux segfaults

I am experiencing a new problem since I upgraded my linux 1.1.64 machine to
gcc 2.7.0 and libg++ 2.7.0a.  I have the following small program (test.C):
  #include <stream.h>
  extern "C" {
    #include <sys/socket.h>
    #include <netdb.h>
  }
  void main() {
      char test[5] = "\177\000\000\001";    /* equivalent to 127.0.0.1  */
      gethostbyaddr(test, 4, AF_INET);      /* segfault on this line  */
  }
  void force_libstdcxx_linkage() { cout << endl; }

When I compile this program (g++ test.C), it segfaults on the 'gethostbyaddr'
line.  However, if I comment out the 'cout << endl;' line, libstdc++.a is not
linked into my program, and the program runs fine without a crash.
My guess is that a problem is caused by static initialization of the libstdc++
library, and this is manifesting itself during the 'gethostbyaddr' io calls.
Unfortunately, I can't reproduce this problem under AIX, so it may be linux-
specific.

Compilation output is given below.

 gcc -v test.C -lg++ -lstdc++
Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.0/specs
gcc version 2.7.0
 /usr/lib/gcc-lib/i486-linux/2.7.0/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=7 -D__ELF__ -Dunix -Di386 -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386) -D__i486__ test.C /tmp/cca00135.ii
GNU CPP version 2.7.0 (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/local/include
 /usr/i486-linux/include
 /usr/lib/gcc-lib/i486-linux/2.7.0/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i486-linux/2.7.0/cc1plus /tmp/cca00135.ii -quiet -dumpbase test.cc -version -o /tmp/cca00135.s
GNU C++ version 2.7.0 (i386 Linux/ELF) compiled by GNU C version 2.7.0.
 /usr/i486-linux/bin/as -V -Qy -o /tmp/cca001351.o /tmp/cca00135.s
GNU assembler version cygnus/linux-2.5.2l.15 (i486-linux), using BFD version cygnus/linux-2.5.2l.11
 /usr/i486-linux/bin/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib/gcc-lib/i486-linux/2.7.0 -L/usr/i486-linux/lib /tmp/cca001351.o -lg++ -lstdc++ -lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o
--
Ingredients: chopped pork shoulder with ham, salt, water, sugar, sodium

2. RH71

3. libg++-2.7.2.7

4. nologin shell

5. g++-2.7.2 and Openserver 5

6. Where can I get gs PostScript viewer for Linux?

7. g++-2.7.2p - BIG floating point problem!

8. HELP! Display Postscript NX

9. libg++-2.7.2.8 setup - help??

10. Where to download libg++-2.7.2 source?

11. Stable gcc-2.7.1/libg++-2.7.1/libc-5.?.?

12. Display attribute for Exceed on Solaris 2.6-2.7

13. libg++-2.7.2.8 setup - help??