I've tried to use a bunch of example programs that make use of "G2++.h" and "g2_X11++.h" but my compiler complains that I don't have those files! Furthermore I can't find any place where I can download such files. All I can find is the old g2 stuff. Does anyone know where I can download what I need to use g2++?!?!?

Dani AI

Generated

Short answer for (and to answer ): there is no official header called "G2++.h" or "g2_X11++.h" in the published g2 distribution. The project ships C headers such as g2.h, g2_X11.h, g2_GIF.h, g2_PS.h (the distro docs and package metadata list those files). (rencurel.essworkshop.org)

If you have example code that uses the "++" names, it either came with a private C++ wrapper or the author misnamed the includes. The practical fix is to include the official C headers and, when compiling as C++, use an extern "C" wrapper to prevent name mangling:

extern "C" {
#include <g2.h>
#include <g2_X11.h>
}

Typical compile/link commands used with g2 (you may need libgd and X11 present) are like:

gcc  -o prog prog.c  -lg2 -lX11 -lgd -lm
g++  -o prog prog.cpp -lg2 -lX11 -lgd -lm

Example use and common link flags appear in community examples. (cboard.cprogramming.com)

How to get/install the library: install your distribution package (Debian/Ubuntu provide a dev package libg2-dev with headers) or build from source (./configure; make; make install) — the source install copies g2.h and device headers into the standard include dirs and the library into lib dirs. Also note g2 is GPL-licensed (not LGPL), so linking into non-GPL programs has legal implications. (packages.debian.org)

Quick troubleshooting checklist:

  • After installing, confirm g2.h and g2_X11.h are in /usr/include or /usr/local/include.
  • If the compiler still says "no such file", add the right -I path.
  • If linking fails, ensure the library is installed and the linker sees it (check /usr/lib, /usr/local/lib or run ldconfig -p | grep g2).
  • If examples still mention the "++" headers, search the example bundle for a local wrapper header (it may be shipped with that example). (rencurel.essworkshop.org)

Thanks to for pointing to the g2 project page originally; use the official headers above when adapting those examples.

Recommended Answers

All 2 Replies

"G2++.h" and "g2_X11++.h"
Are they realy exist?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.