Thread: "gtypes.h" No such file or directory

  1. #1
    Registered User
    Join Date
    Jan 2016
    Posts
    84

    "gtypes.h" No such file or directory

    Hi,

    I want to draw pixels on the screen, so I eventually knew that I need "graphics.h" to use "putpixel(x,y)" function.

    But I don't know why it's not working and not initialing the graphics screen.

    So with some search I found this link and it contains another "graphics.h" library but with different content.

    Link:
    ../common/include/graphics.h

    So I moved the original one temporary and replaced it with this one, and when I compile it I get this error.

    What to do ?

    My test code is this:
    Code:
    #include  <graphics.h>#include  <iostream>
    
    
    int main(){
    
    
    initGraphics(400,400);
    
    
    
    
    	return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Let's start with the basics - which OS are you using?

    There is no such thing as "graphics" in standard C++.

    You have to physically locate and install some kind of graphics library matched to your OS and compiler.

    Randomly copying header files from the internet isn't the way to go.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2016
    Posts
    84
    Quote Originally Posted by Salem View Post
    Let's start with the basics - which OS are you using?
    Windows 10

    There is no such thing as "graphics" in standard C++.
    Yeah, I actually mixed things up !

    I followed a tutorial on GeeksforGeeks to include graphics.h for C code.
    Here:
    How to include graphics.h in CodeBlocks? - GeeksforGeeks

    I installed the libs mentioned in the tutorial. And then when I went throw the library in the link I posted in the main post, I just opened the "graphics.h" and replaced the code with the one in the tutorial.

    But I lost actually.

    1. The 1st "graphics.h" in GeeksforGeeks tutorial is for C code.
    2. The 2nd "graphics.h" in Stanford link is for C++ code.

    But since all the include libs are in:
    Code:
    Program_Files\CodeBlocks\MinGW\include
    So I thought that path would contain all C/C++ libraries, is that true or I'm just building false assumptions ?

    You have to physically locate and install some kind of graphics library matched to your OS and compiler.
    I did that based on GeeksforGeeks tutorial. But it even didn't work as explained in the tutorial.

    I didn't get the graphics screen.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Step 3 : Copy and paste graphics.h and winbgim.h files into the include folder of compiler directory.
    This is bad advice.
    - You don't know if something with the same name is already there.
    - You don't know if some future compiler upgrade won't trash your copied in files.

    > Step 5 : Open Code::Blocks. Go to Settings >> Compiler >> Linker settings.
    What you should be doing is adding the directory where you saved graphics.h etc to the compiler and linker search paths (the other tabs).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jan 2016
    Posts
    84
    Quote Originally Posted by Salem View Post
    > Step 3 : Copy and paste graphics.h and winbgim.h files into the include folder of compiler directory.
    This is bad advice.
    - You don't know if something with the same name is already there.
    I didn't get a message telling me that there's another file with the same name and it's my recent fresh Code::Blocks install on this rig.

    - You don't know if some future compiler upgrade won't trash your copied in files.
    How these upgrades work ? And which parts of the IDE is getting the upgrade ?
    For example, in my mingw path there are:
    &quot;gtypes.h&quot; No such file or directory-mingw_path_stuff-jpg



    > Step 5 : Open Code::Blocks. Go to Settings >> Compiler >> Linker settings.
    What you should be doing is adding the directory where you saved graphics.h etc to the compiler and linker search paths (the other tabs).
    I did that.


    What I want to do, is I just want to work with pixels.

    I could try to work with Processing, I think processing accepts different programming languages. I would ask this question in their forum about the languages that Processing accepts.

    But I would give it try with codeblocks since it's my C/C++ compiler.

  6. #6
    Registered User
    Join Date
    Jan 2016
    Posts
    84
    Also how does it work with installing C or C++ libraries. Are they in the same directory ?

    If I want to solve the error in the main post and start working with that header file, how to do that ? I think there should be a source file that contain the functions definitions for that C++ header file.

    But in Stanford link, it says "The Stanford C++ Libraries", does that mean it's their special C++ libraries and not the ones that comes with common C++ compilers like mingw ?

    This is the link to the list of their C++ libraries link:
    The Stanford C++ Libraries

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Warning: C++ Libraries normally need to be used with the exact C++ compiler that created them!

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Aug 2019
    Location
    inside a singularity
    Posts
    308
    Just a tip: It's a terrible terrible idea to try and use graphics.h in C::B. Speaking from personal experience. Invest time in learning something like OpenGL or DirectX or Metal, etc as I highly doubt graphics.h being used anywhere in the present except maybe in India for school projects on Turbo C++.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook, The Wizardry Compiled

  9. #9
    Registered User
    Join Date
    Jan 2016
    Posts
    84
    Quote Originally Posted by stahta01 View Post
    Warning: C++ Libraries normally need to be used with the exact C++ compiler that created them!

    Tim S.
    What you mean exactly ?

    What I'm doing wrong ?

    Quote Originally Posted by Zeus_ View Post
    Just a tip: It's a terrible terrible idea to try and use graphics.h in C::B. Speaking from personal experience. Invest time in learning something like OpenGL or DirectX or Metal, etc as I highly doubt graphics.h being used anywhere in the present except maybe in India for school projects on Turbo C++.
    I'm sorry I didn't explain my main goal for going with something that is relatively low level and of course old programming style.

    Actually I'm trying to work with pixels because I'm working with embedded systems graphics on LCDs that have simple drivers which work on drawing pixels from bitmaps.

    So I'm trying to learn some skills of working with pixels because the whole library is based on learning how a pixel is drawn on the LCD and at which frame buffer pattern.

    This is the library I'm working on now. It's for 0.96" LCD for microcontrollers projects.

    Code:
    #include <avr/pgmspace.h>#include <stdlib.h>
    #include <Wire.h>
    #include "ssd1306_stm32.h"
    #include "ssd1306_stm32_arrays.h"
    
    
    #ifndef swap
    #define swap(a, b) { int16_t t = a; a = b; b = t; }
    #endif
    
    
    // lcd draw functions
    /* void ssd1306_(){}
    void ssd1306_(){}
    void ssd1306_(){}
    void ssd1306_(){}
    void ssd1306_(){} */
    
    
    // the most basic function, set a single pixel
    void ssd1306_drawPixel(int16_t x, int16_t y, uint16_t color){
    	
      if ((x < 0) || (x >= width) || (y < 0) || (y >= height))
        return;
    
    
      // check rotation, move pixel around if necessary
      switch (rotation) {
      case 1:
        swap(x, y);
        x = width - x - 1;
        break;
      case 2:
        x = width - x - 1;
        y = height - y - 1;
        break;
      case 3:
        swap(x, y);
        y = height - y - 1;
        break;
      }  
    
    
      // x is which column
        switch (color) 
        {
          case WHITE:   buffer[x+ (y/8)........D1306_WIDTH] |=  (1 << (y&7)); break;
          case BLACK:   buffer[x+ (y/8)........D1306_WIDTH] &= ~(1 << (y&7)); break; 
          case INVERSE: buffer[x+ (y/8)........D1306_WIDTH] ^=  (1 << (y&7)); break; 
        } 
    }
    
    
    
    
    void ssd1306_byte_write(uint8_t x, uint8_t y, uint8_t data_byte){
    	ssd1306_cmd(SSD1306_COLUMNADDR); ssd1306_cmd(x); ssd1306_cmd(x);
    	ssd1306_cmd(SSD1306_PAGEADDR);   ssd1306_cmd(y); ssd1306_cmd(y);
    	ssd1306_data(data_byte);
    }
    
    
    void ssd1306_spec_bitmap(uint8_t x, uint8_t y, uint8_t w, 
    						 uint8_t h, const unsigned char * bitmap){
    	ssd1306_cmd(SSD1306_COLUMNADDR); ssd1306_cmd(x); ssd1306_cmd(x);
    	ssd1306_cmd(SSD1306_PAGEADDR);   ssd1306_cmd(y); ssd1306_cmd(y);
    	
    	x = 50;
    	y = ;
    	
    	
    	for (uint16_t i=x0; i<x1; i++) {
    		Wire.beginTransmission(_i2caddr);
    		WIRE_WRITE(DAT_MSK);
    		for (uint8_t x=0; x<16; x++) {
    			WIRE_WRITE(pgm_read_byte_near(&bitmap[i]));
    			i++;
    		}
    		i--;
    		Wire.endTransmission();
    	}	
    }
    
    
    void ssd1306_drawbitmap(int16_t x, int16_t y,
      const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {
    
    
        int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
        uint8_t byte = 0;
    
    
    	Wire.beginTransmission(_i2caddr);
    	WIRE_WRITE(DAT_MSK);
        for(int16_t j=0; j<h; j++, y++) {
            for(int16_t i=0; i<w; i++) {
                if(i & 7) byte <<= 1;
                else      byte   = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
                if(byte & 0x80) writePixel(x+i, y, color);
            }
        }
        endWrite();
    }
    I just want to save time in uploading a code to the microcontroller everytime and instead work with a similar simulated code with computer programming with drawing pixels on the screen.

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    The graphics.h for your PC is of no use to your embedded LCD microcontroller project.
    Except perhaps as a list of function ideas that you need to implement.

    Arduino Library & Examples | Monochrome OLED Breakouts | Adafruit Learning System
    Using these OLEDs with Arduino sketches requires that two libraries be installed: Adafruit_SSD1306, which handles the low-level communication with the hardware, and Adafruit_GFX, which builds atop this to add graphics functions like lines, circles and text.
    It seems like the Adafruit_GFX is where you want to be.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    Registered User
    Join Date
    Jan 2016
    Posts
    84
    Yes I know, but I want to simulate the LCD with the computer monitor.

    Because it would be easier doing the programming with computer simulated screen and then when I finish testing the functions I upload the program to the microcontroller.

    Reasons I want to do this is because when sometimes I'm travelling and I'm on a plane and don't want to plug the mcu board and want to just work on the laptop and do some programming for my embedded projects.

    I found that Processing is the one that is really set for this stuff, but I trying to put some C coding there and test my work.

    If it worked then I don't have to search for drawing pixels with codeblocks. I could not find a C library that provide functions to draw pixels on the screen, even I couldn't launch the graphics screen with "graphics.h" library !

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you go up a level to say CS106B: Programming Abstractions in C++, each "Starter code" pack contains the full library.

    Unfortunately for you, the pre-build library would seem to have been built for some version of visual studio.

    Maybe that works for your MinGW - I don't know.

    My goto PC libraries would be Simple DirectMedia Layer - Homepage or SFML
    They're more likely to work out of the box, and more useful to know in the long term.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  13. #13
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Salem View Post
    If you go up a level to say CS106B: Programming Abstractions in C++, each "Starter code" pack contains the full library.
    Thank you for the C++ link; looks like it might be the correct level for me to try to do.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why gentenv("PWD") doesn't work in home directory?
    By jjwooyoung in forum C Programming
    Replies: 1
    Last Post: 11-12-2016, 08:05 PM
  2. Replies: 2
    Last Post: 12-08-2014, 08:12 PM
  3. get "application data" directory in xp, vista
    By sgh in forum Windows Programming
    Replies: 8
    Last Post: 05-12-2008, 02:48 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM

Tags for this Thread