Friday, April 20, 2012

Install libgraph library in GCC

Step #1.Install the following in Synaptic Package Manager
  • libsdl-image1.2
  • libsdl-image1.2-dev
  • guile-1.8-dev
  • guile-1.8 
Step #2. Download and install libgraph then
  • ./configure
  • sudo make
  • sudo make install
Step #3  Include graphics.h in your C program . Initialize the graphics system by
  • int gd=DETECT, gm=VGAMAX;
  • initgraph(&gd, &gm, NULL);

Step #4 you need to copy all the libgraph shared files from /usr/local/lib to /usr/lib
  •  sudo cp /usr/local/lib/libgraph.* /usr/lib

Now Compile the program  using following command : gcc filename.c -lgraph



Enjoy !!!!

9 comments:

  1. root@jec-WIV59605-0002:~/libgraph-1.0.2# sudo make
    make: *** No targets specified and no makefile found. Stop.



    I don't know what to do..
    Please help!!!

    ReplyDelete
  2. I'm getting below error. Please let me know if there is any solution for this.
    [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
    [xcb] Aborting, sorry about that.
    a.out: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

    ReplyDelete
  3. Very tankful to you for such a nice effeort

    ReplyDelete
  4. [root@localhost Desktop]# ./a.out
    The font has not been loaded!
    what i do?

    ReplyDelete
  5. Thank you so much. It's really good for me. It should be better if you add more explanation for each step.

    ReplyDelete
  6. It's not working in Ubuntu 14.04. Please help!
    After compiling my code, I get following error

    /tmp/cck8KKwR.o: In function `main':
    line.c:(.text+0x13): undefined reference to `grprintf'
    line.c:(.text+0x29): undefined reference to `grscanf'
    line.c:(.text+0x38): undefined reference to `grprintf'
    line.c:(.text+0x4e): undefined reference to `grscanf'
    line.c:(.text+0x5d): undefined reference to `grprintf'
    line.c:(.text+0x73): undefined reference to `grscanf'
    line.c:(.text+0x82): undefined reference to `grprintf'
    line.c:(.text+0x98): undefined reference to `grscanf'
    line.c:(.text+0xab): undefined reference to `detectgraph'
    line.c:(.text+0xc3): undefined reference to `initgraph'
    line.c:(.text+0x16f): undefined reference to `putpixel'
    line.c:(.text+0x19e): undefined reference to `delay'
    line.c:(.text+0x1b2): undefined reference to `grgetch'
    line.c:(.text+0x1b7): undefined reference to `closegraph'
    collect2: error: ld returned 1 exit status

    ReplyDelete
  7. muchas gracias me sirvio de mucho

    ReplyDelete