Error: 'QRCOPE' was not declared in this scope 7 | QRCode QRCOPE; | ^~~~~~ I would like to help. I experienced the problem of QRCODE

#include "qrcode.h"

void setup() {
    Serial.begin(115200);

strong text
    uint32_t dt = millis();
  
    // Create the QR code
    QRCode qrcode;
    uint8_t qrcodeData[qrcode_getBufferSize(3)];
    qrcode_initText(&qrcode, qrcodeData, 3, 0, "HELLO WORLD");
  
    // Delta time
    dt = millis() - dt;
    Serial.print("QR Code Generation Time: ");
    Serial.print(dt);
    Serial.print("\n");

    // Top quiet zone
    Serial.print("\n\n\n\n");

    for (uint8_t y = 0; y < qrcode.size; y++) {

        // Left quiet zone
        Serial.print("        ");

        // Each horizontal module
        for (uint8_t x = 0; x < qrcode.size; x++) {

            // Print each module (UTF-8 \u2588 is a solid block)
            Serial.print(qrcode_getModule(&qrcode, x, y) ? "\u2588\u2588": "  ");

        }

        Serial.print("\n");
    }

    // Bottom quiet zone
    Serial.print("\n\n\n\n");
}

void loop() {

}

This is the code that I use, causing the said problem. Currently, trying to install both QRCode Libery and EspQrcode Libery.

We need to see the verbose error log in code tags.

'void setup()':
C:\Users\ADMIN\AppData\Local\Temp.arduinoIDE-unsaved202519-12148-qiitn9.mgqj\QRCode\QRCode.ino:7:5: error: 'QRCode' was not declared in this scope
7 | QRCode qrcode;
|

Compilation error: 'QRCode' was not declared in this scope

////It has been shown like this.////

Hi @aniki-19. The problem is that the ESP32 SDK contains a file named qrcode.h. So the the Arduino sketch build system finds that file and doesn't use the "QRCode" library when compiling your sketch.

The workaround for this problem is to add a header file to the library with a unique name, then add an #include directive for that file to your sketch before the #include directive for the ambiguous file.

I'll provide instructions you can follow to do that:

  1. Start Arduino IDE if it is not already running.
  2. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  3. Take note of the path shown in the "Sketchbook location" field of the dialog.
  4. Click the "CANCEL" button.
    The "Preferences" dialog will close.
  5. Create a new file at the following path on your hard drive:
    <sketchbook location>\libraries\QRCode\src\QRCode_Library.h
    
    (where <sketchbook location> is the path you saw in the "Sketchbook location" preference)
    • :exclamation: Make sure the file is named exactly QRCode_Library.h, not something like QRCode_Library.h.txt
    • We are intentionally leaving the QRCode_Library.h file empty of any code, but if you like you can add a comment in the file to explain its purpose.
  6. Add the following line to the top of your sketch:
    #include <QRCode_Library.h>
    
    :exclamation: The line must be placed above the #include directive for qrcode.h

Now try to compile or upload your sketch again. Hopefully this time it will be successful.

1 Like

Thank you very much. I can solve this problem. Because you really help

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per