hie guys l have basic knowledge of c and c++.Recently we were given a project assignment on statistical modelling we have to implement it using c/c++.I researched on the libarries that l can use eg sdl,openGL,what l wld like to noe is it possible to code using gcc in linux, does gcc have graphics library or l should do something else.any assistance will be highly appreciated

Recommended Answers

All 2 Replies

Yes you could use C as the programming language medium for a graphics application and use gcc to compile it but you need to include the openGL header files such as gl/gl.h, etc. which aren't native gcc header files

does gcc have graphics library

Not by default. GCC only includes the standard libraries (C/C++ standard libraries). For everything else, you need external libraries. The nice thing with Linux is that you can very easily install those external libraries and start using them right away, with little trouble. In your package management software, you will find libraries marked as "dev" or "devel" which means that it will install development files needed to write applications for them (usually including library binaries (.a and .so files) and header files, in the standard system directories /usr/lib and /usr/include, respectively). Most libraries will start with the prefix "lib" (e.g., such as libsdl1.2-dev for SDL development files).

I researched on the libraries that l can use eg sdl, openGL, what l wld like to noe is it possible to code using gcc in linux

For SDL, you should look up "libsdl" on your package management system and install all the "-dev" (or "-devel") that seems useful (probably libsdl1.2-dev, libsdl-image1.2-dev, and libsdl-gfx1.2-dev). For OpenGL, it should already be installed by whatever graphics driver you have, including its development files. You can #include "GL/gl.h" and add -lGL to your compilation command, and it should work. Just follow simple SDL-OpenGL tutorials, like these ones and then these OpenGL tutorials.

If I may suggest an additional library to look at, I would recommend looking at Coin3D. This is an open-source implementation of OpenInventor (a sort-of extension of OpenGL that slaps a higher-level C++ API on top of OpenGL, making it much easier to construct scene-graphs). A couple of weeks ago I used it for the first time, after about 30min I had the basic tutorial code running and was starting to play around with it (adding shapes, animations, etc.). It is super easy and carefree (although the C++ coding-style it uses is a bit antiquated, but OK). Just install libcoin60-dev libcoin60-doc libcoin60-runtime libsoqt4-dev, and you should be able to run this tutorial code and play around with it using instructions from the Inventor Mentor. Of course, OpenInventor is more tailored towards simple 3D graphics, like primitive shapes and simple textures, i.e., the kind of graphics you would find in a CAD tool or something. For more computer game style graphics, checkout Ogre3D, which is also very easy and installable from the package manager. If it is more graphics in the sense of user interface (GUI), then I recommend Qt, which is, again, installable from the package manager, along with QtDesigner / QtCreator, and is also usable with OpenGL (via QGLWidget) or Coin3D (via SoQt library).

Be a part of the DaniWeb community

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