Linker error in C. while using <graphics.h> Turbo C++
24,705
Solution 1
If you are using Turbo C .. just need to check one option:
Go to Options->Linker->Libraries
and check the Graphics Library option
Solution 2
Go to options>>linker>>libraries
and instead of:
initgraph(&gd,&gm,"");
Write:
initgraph(&gd,&gm,"..\\BGI);
Author by
MELWIN
Updated on April 07, 2022Comments
-
MELWIN about 2 years
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?
-
Andreas Fester over 10 yearsYou need to link against
graphics.lib
, and you should probably consider switching to a more recent compiler -
adrin over 10 yearsPlease edit the title and add Turbo C to it.
-
adrin over 10 yearshahahaha, love that you remember this, lol. Apparently people still use TC, Borland should be proud :P
-
Digital_Reality over 10 years@adrin yeah.. stopped using this now but I know I too got trouble using it :D
-
MELWIN over 10 years@Digital_Reality:sad no one find this question useful... :( thank you for the answer sir :)
-
MELWIN over 10 years@Digital_Reality sir in output i got the message " Graphics not initialized use ('initgraph') . What should I do ???
-
Digital_Reality over 10 years@MELWIN Err.. time changes buddy! :) We have to stick to it.. Anyway when are you moving to new compiler? :D
-
Digital_Reality over 10 yearsUm.. I am not sure what might be solution.. but check this link daniweb.com/software-development/c/threads/76092/…