-1

I've been having some problems trying to figure out with header is useful to manage to get a screen, and draw shapes in it, using C.

Tried to use 'graphics.h' but is not working for me, I think maybe 'graphics.h' is meant to be used in C++ and not C? I really don't know and would appreciate it if someone knows anything.

genpfault
  • 51,148
  • 11
  • 85
  • 139
mpenalozag
  • 53
  • 1
  • 5
  • 2
    Does this answer your question? [How can I get and use the header file in my C++ program?](https://stackoverflow.com/questions/7860569/how-can-i-get-and-use-the-header-file-graphics-h-in-my-c-program) – kaylum Dec 02 '21 at 03:58
  • 2
    There is no standard library for graphics in C. This depends on your operating system, amongst other factors. Some common and reasonably well-supported libraries across multiple platforms are OpenGL and Qt. Beyond this, specify your target operating system. `graphics.h` sounds like an ancient Windows or DOS library. – paddy Dec 02 '21 at 03:59
  • Ahh, yes... TurboC. That's where I remember it from! Hahah thanks for the link, kaylum. – paddy Dec 02 '21 at 04:00
  • I'm trying to get display of graphics in C language, having everything installed in WSL (Ubuntu dist) – mpenalozag Dec 02 '21 at 04:01
  • I checked the link sent by kaylum. Tried with the SDL option and didn´t got it to work :( – mpenalozag Dec 02 '21 at 04:04

2 Answers2

1

On Linux, you can't build a graphical app using only stdlib. You have to add something like OpenGL, Xlib, maybe Qt or even SFML. Good luck to make an app)

Ilush
  • 64
  • 3
1

I believe graphics.h is a Windows-specific library. Assuming you're on Linux, you can use gfx.

gfx is an xlib-based graphics library with some very basic functions to draw lines/pixels and get keyboard input. I wouldn't use it in a serious project, but it's fairly easy to get started with. You can even add functionality to draw more complex shapes if you mess with the source code and some XLib functions.

If that's too basic, you can use SDL2 for 2D graphics, OpenGL for 3D graphics, and ncurses for terminal-based graphics.