Strange Undefined Reference for a function - ESP23

I am trying to make the attached project, which compiles perfectly for Arduino straight out of the box, to compile for my ESP32 Dev Board.

I had a few reference issues which I got sorted.

The "Undefined reference" I am left with I can't figure out.

  1. In the .INO file, the libraries GUI_Paint.h and image.h are referenced.
  2. All the "Paint_" functions, except "Paint_DrawImage", are accessible, and when pressing F12 on them I am taken to the actual function in GUI_Paint.cpp
  3. The references for Paint_DrawImage look the same as with the others, but the actual function is not accessible. F12 only takes me to the declaration in GUI_Paint.h and not the function in GUI_Paint.cpp

As mentioned before, it compiles fine straight out the box for Arduino.

Any help would be appreciated.

LCD_2inch4.zip (45.2 KB)

Generally we dont open .zip files.
If you want help you will need to post following these guidelines

I will go and check the guidelines as suggested but I don't see why you see it as a joke? I wanted to give proper context so I am very sorry that I have offended you. I purposely did not want to just post snippets. So what is enough and what is too little?

I guess the question is what is too much :slight_smile:

but if your project needs all this to compile and it was hard to make a simpler code exhibiting the same issue, then that's OK for me

what would have helped is more precision on the error you get. copy the full console output when the compile fails and paste it here in code tags. Sometimes it's enough to provide guidance.

1 Like

the compiler noticed in GUI_Paint.cpp

    //Debug("mirror should be MIRROR_NONE, MIRROR_HORIZONTAL, \

and said

GUI_Paint.cpp:122:5: error: multi-line comment [-Werror=comment]
     //Debug("mirror should be MIRROR_NONE, MIRROR_HORIZONTAL, \
     ^
cc1plus: some warnings being treated as errors

a slash at the end of a line means to the compiler don't take into account the end of line and proceed as if the next line was here on the same line...

So I added a // on the next line

  } else {
    //Debug("mirror should be MIRROR_NONE, MIRROR_HORIZONTAL, 
    //    MIRROR_VERTICAL or MIRROR_ORIGIN\r\n");
    //exit(0);
  }

and kept compiling and got

LCD_2inch4.ino:25: undefined reference to `Paint_DrawImage(unsigned char const*, unsigned short, unsigned short, unsigned short, unsigned short)'
collect2: error: ld returned 1 exit status

the function Paint_DrawImage() is declared in your GUI_Paint.h file which you included but in the .cpp its signature is

void Paint_DrawImage(const char *image, UWORD xStart, UWORD yStart, UWORD W_Image, UWORD H_Image)

and in the .h its signature is

void Paint_DrawImage(const unsigned char *image,UWORD Startx, UWORD Starty,UWORD Endx, UWORD Endy); 

see this little unsigned difference ? ➜ it's enough to tell the compiler that you had different functions.

as your image is defined as unsigned char, the .cpp and .h should both include unsigned

once you fixed this compilation will go through.

Thanks so much JML. I totally missed that unsigned bit and it now compiles. I feel silly for missing that but yeah. Thanks again

fresh pair of eyes helps :slight_smile:

So true!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.