Linker error in C. while using <graphics.h> Turbo C++
Asked Answered
J

2

6

I have entered the following code in turbo c++.

    #include<graphics.h>
    #include<conio.h>
    int main()
    {
    int gd= DETECT, gm;
    initgraph(&gd,&gm,"D:\\TC\\BGI");
    getch();
    closegraph();
    return 0;
    }

It compiles without any errors and warning. But when I run the program the following errors are displayed

  • Linker Error: Undefined symbol_closegraph in module G1.C
  • Linker Error: Undefined symbol_initgraph in module G1.C

note : The BGI folder is in the path D:\TC\

How can I solve the problem?

Jetliner answered 14/1, 2014 at 10:23 Comment(2)
You need to link against graphics.lib, and you should probably consider switching to a more recent compilerSuprasegmental
Please edit the title and add Turbo C to it.Depravity
W
9

If you are using Turbo C .. just need to check one option:

Go to Options->Linker->Libraries and check the Graphics Library option

Worlock answered 14/1, 2014 at 10:26 Comment(6)
hahahaha, love that you remember this, lol. Apparently people still use TC, Borland should be proud :PDepravity
@Depravity yeah.. stopped using this now but I know I too got trouble using it :DWorlock
@Digital_Reality:sad no one find this question useful... :( thank you for the answer sir :)Jetliner
@Worlock sir in output i got the message " Graphics not initialized use ('initgraph') . What should I do ???Jetliner
@Jetliner Err.. time changes buddy! :) We have to stick to it.. Anyway when are you moving to new compiler? :DWorlock
Um.. I am not sure what might be solution.. but check this link daniweb.com/software-development/c/threads/76092/…Worlock
W
3

Go to options>>linker>>libraries and instead of:

initgraph(&gd,&gm,"");

Write:

initgraph(&gd,&gm,"..\\BGI);
Watermark answered 25/3, 2018 at 9:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.