0

i keep getting this error when i try to run a simple graphics code. and i dont think the problem is with the code itself.

Desktop\CG> g++ -w bres-circle.cpp -o bres-circle -lgraph
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgraph
collect2.exe: error: ld returned 1 exit status

Here is the code :

#include <iostream>
#include <graphics.h>

using namespace std;

int main()
{
    int gd = DETECT, gm;
    initgraph(&gd, &gm,"");

    line(100,100,200,200);
    closegraph();
}

Botje
  • 26,269
  • 3
  • 31
  • 41
  • Does this answer your question? [Error due to #include](https://stackoverflow.com/questions/27839752/error-due-to-includegraphics-h) – Botje Apr 14 '20 at 08:01
  • `-lgraph` means "link in libgraph.a or libgraph.so". Do you have either of those files, and are they in a place that g++ can find them? (It might also accept libgraph.lib for Windows-targeted compilers.) If you need to specify an extra library path then that's `-L `, and put that before the `-lgraph`. – Rup Apr 14 '20 at 08:07
  • (There may also be command line parameter order issues - the order for linking is significant. Maybe try putting the -lgraph before the -o too? But I don't think that's a problem.) – Rup Apr 14 '20 at 08:08

0 Answers0