MFRC522 Library Compiler Issues

Hey all,

I have years of programming experience behind me, but I am very new to using Arduino.

Here’s the issue I’m facing:

I have downloaded this library: GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522
I’ve loaded the DumpInfo example project but it won’t compile.

This is the error I’m receiving:

In file included from /home/alex/sketchbook/libraries/MFRC522/MFRC522.h:78:0,
                 from DumpInfo.ino:37:
/home/alex/sketchbook/libraries/MFRC522/require_cpp11.h:9:2: error: #error "This library needs at least a C++11 compliant compiler, maybe compiler argument for C++11 support is missing or if you use Arduino IDE upgrade to version >=1.6.6"
 #error "This library needs at least a C++11 compliant compiler, maybe compiler argument for C++11 support is missing or if you use Arduino IDE upgrade to version >=1.6.6"
  ^
In file included from DumpInfo.ino:37:0:
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:146:2: warning: identifier ‘constexpr’ is a keyword in C++11 [-Wc++0x-compat]
  static constexpr byte FIFO_SIZE = 64;  // The FIFO is 64 bytes.
  ^
In file included from DumpInfo.ino:37:0:
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:374:2: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
  StatusCode PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false);
  ^
In file included from DumpInfo.ino:37:0:
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:146:9: error: ‘constexpr’ does not name a type
  static constexpr byte FIFO_SIZE = 64;  // The FIFO is 64 bytes.
         ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:146:9: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:148:9: error: ‘constexpr’ does not name a type
  static constexpr uint8_t UNUSED_PIN = UINT8_MAX;
         ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:148:9: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:152:22: warning: scoped enums only available with -std=c++11 or -std=gnu++11
  enum PCD_Register : byte {
                      ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:227:21: warning: scoped enums only available with -std=c++11 or -std=gnu++11
  enum PCD_Command : byte {
                     ^
In file included from DumpInfo.ino:37:0:
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:242:20: warning: scoped enums only available with -std=c++11 or -std=gnu++11
  enum PCD_RxGain : byte {
                    ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:257:22: warning: scoped enums only available with -std=c++11 or -std=gnu++11
  enum PICC_Command : byte {
                      ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:291:19: warning: scoped enums only available with -std=c++11 or -std=gnu++11
  enum PICC_Type : byte {
                   ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:307:20: warning: scoped enums only available with -std=c++11 or -std=gnu++11
  enum StatusCode : byte {
                    ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:374:111: error: ‘nullptr’ was not declared in this scope
  StatusCode PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false);
                                                                                                               ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:375:112: error: ‘nullptr’ was not declared in this scope
  StatusCode PCD_CommunicateWithPICC(byte command, byte waitIRq, byte *sendData, byte sendLen, byte *backData = nullptr, byte *backLen = nullptr, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false);
                                                                                                                ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:375:137: error: ‘nullptr’ was not declared in this scope
  StatusCode PCD_CommunicateWithPICC(byte command, byte waitIRq, byte *sendData, byte sendLen, byte *backData = nullptr, byte *backLen = nullptr, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false);
                                                                                                                                         ^
/home/alex/sketchbook/libraries/MFRC522/MFRC522.h:375:164: error: ‘nullptr’ was not declared in this scope
  StatusCode PCD_CommunicateWithPICC(byte command, byte waitIRq, byte *sendData, byte sendLen, byte *backData = nullptr, byte *backLen = nullptr, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false);
                                                                                                                                                                    ^

I’ve looked into Arduino IDE C++11 compliance, but the version I’m using (1.8.12) is by default C++11 compliant. I double checked the platform.txt file and it has the relevant flag in the correct place. I’ve also reformatted all .cpp files to .c files which I saw was suggested as a fix elsewhere on the internet. This did not work, so I’ve formatted them back to .cpp.

Also, this is worth mentioning:
When I first tried to compile, it was saying that it could not locate the .h files the example sketch tries to include, despite the library manager acknowledging the library. After a bit of digging, I discovered that this was because they were tucked away in a Src file in the library. So I moved all the code out of the Src folder and in to the root folder of the library. That fixed the error where the IDE couldn’t locate the code, but now I get the error above. This doesn’t seem to be a common issue at all, but my assumption is that because I’m using Linux, maybe it was to do with that.

Useful Info:

IDE Version: 1.8.12
OS: Ubuntu
Arduino Board: Elegoo UNO

Here is the full code of the sketch I am trying to compile:

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN         9          // Configurable, see typical pin layout above
#define SS_PIN          10         // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

void setup() {
	Serial.begin(9600);		// Initialize serial communications with the PC
	while (!Serial);		// Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
	SPI.begin();			// Init SPI bus
	mfrc522.PCD_Init();		// Init MFRC522
	delay(4);				// Optional delay. Some board do need more time after init to be ready, see Readme
	mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
	Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
	// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}

	// Dump debug info about the card; PICC_HaltA() is automatically called
	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

Also, last note: the same error appears if include these libraries in a blank sketch

Thanks so much to anyone who can assist me!
-Alex