Header Ads

How to run C/C++ graphics programs on Ubuntu

In Ubuntu, we need to  install libgraph library that contains graphics.h header file and other important files to be able to run any graphics program . libgraph is an implementation of the TurboC graphics API (graphics.h) on GNU/Linux using SDL.

Follow these steps to install libgraph on ubuntu:

  1. Open terminal. (ctrl + shift + T). Copy paste the following command. It will download and update the packages in your system. (it requires Internet connection).

    sudo apt-get update



  2. After that execute the following command to install SDL(Simple DirectMedia Layer) packages.

    sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev



  3. Now, download libgraph package from here

  4. Extract that file and open the extracted folder and right click on empty space and click open in terminal.In terminal execute following commands one by one:

    . /configure

    sudo make install

    sudo cp /usr/local/lib/libgraph.* /usr/lib



  5. You have successfully installed libgraph package.
    You can compile a graphics program by typing following commands:
    For C++ program

    g++ <program_name>.cpp – lgraph


    For C program:

    gcc <program_name>.c – lgraph



  6. To run the program, use following command

    ./a.out



4 comments:

Powered by Blogger.