Cannot compile mirf.h and nRF24L01.h libraries...

I’m trying to get my nRF24L01 transceivers to work and cannot even get past compiling (verifying) a base sketch… for some reason, I cannot compile the “mirf.h” and “nRF24L01.h” libraries (not even trying to upload yet, just VERIFY the code). It’s also strange that I CAN successfully without error compile the “Nrf2401.h” library just fine (no errors)… but I have the nRF24L01 transceivers, so I figure the older library will not work.

Below is just a bare-minimum sketch to eliminate any errors in my coding and I still get the errors (further down).

#include <mirf.h>
#include <nRF24L01.h>

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

Error message:

In file included from D:\Arduino\libraries\nRF24L01\mirf.c:29:
D:\Arduino\libraries\SPI/spi.h:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘SPIClass’
D:\Arduino\libraries\SPI/spi.h:53: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘SPI’
D:\Arduino\libraries\SPI/spi.h:55: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘:’ token
D:\Arduino\libraries\SPI/spi.h:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘:’ token
D:\Arduino\libraries\SPI/spi.h:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘:’ token
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_init’:
D:\Arduino\libraries\nRF24L01\mirf.c:46: error: ‘PB1’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c:46: error: (Each undeclared identifier is reported only once
D:\Arduino\libraries\nRF24L01\mirf.c:46: error: for each function it appears in.)
D:\Arduino\libraries\nRF24L01\mirf.c:46: error: ‘PB0’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_config’:
D:\Arduino\libraries\nRF24L01\mirf.c:81: error: ‘PB0’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_set_RADDR’:
D:\Arduino\libraries\nRF24L01\mirf.c:87: error: ‘PB0’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: At top level:
D:\Arduino\libraries\nRF24L01\mirf.c:105: error: expected identifier or ‘(’ before ‘{’ token
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_data_ready’:
D:\Arduino\libraries\nRF24L01\mirf.c:131: error: ‘PB1’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_get_data’:
D:\Arduino\libraries\nRF24L01\mirf.c:140: error: ‘PB1’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_config_register’:
D:\Arduino\libraries\nRF24L01\mirf.c:150: error: ‘PB1’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_read_register’:
D:\Arduino\libraries\nRF24L01\mirf.c:159: error: ‘PB1’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_write_register’:
D:\Arduino\libraries\nRF24L01\mirf.c:168: error: ‘PB1’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c: In function ‘mirf_send’:
D:\Arduino\libraries\nRF24L01\mirf.c:181: error: ‘PB0’ undeclared (first use in this function)
D:\Arduino\libraries\nRF24L01\mirf.c:186: error: ‘PB1’ undeclared (first use in this function)

Have searched far and wide through at least 100+ web pages for an answer… please help! I’m very new to all of this but trying to learn fast!

I cannot compile the "mirf.h" and "nRF24L01.h" libraries

Which you got from where?

What version of the IDE are you using? On what OS? (Though OS shouldn't matter, but more data is better than less data.)

Sorry. I’m running IDE 1.0.1 on Windows 7. I downloaded the library here: http://arduino.cc/playground/InterfacingWithHardware/Nrf24L01 << doesn’t work

http://www.arduino.cc/playground/InterfacingWithHardware/Nrf2401 << works (but not right version for my transceivers)

The fact that the library comes with pde files, and that Mirf.h includes WProgram.h should tell you that that library has not been updated to work with 1.0+.

Interestingly, 1.0 produces completely different error messages. Only one, actually, that says that WProgram.h couldn't be found.

Apparently, missing include files are no longer fatal errors in 1.0.1. A giant step "forward".

So I went ahead and tried out the library going back to IDE 0020 and still no go... has this library ever worked? It's published on the Arduino.cc playground...

Does anyone know of an nRF24L01 library that works that I can try?

and still no go

No error messages == no help.

I've just downloaded the library from http://arduino.cc/playground/InterfacingWithHardware/Nrf24L01. All the example sketches compiled ok in IDE 022, as did your bare-minimum sketch, once I added SPI.h to it.

So strange… so I tried what you did with IDE 0022 and running the examples from: http://arduino.cc/playground/InterfacingWithHardware/Nrf24L01

But still getting the below errors… I’ve even tried picking different boards (Mega1280, Mega2560, etc). No even trying to upload, just verify/compile… what am I missing/doing wrong?

/**

  • Pins:
  • Hardware SPI:
  • MISO → 12
  • MOSI → 11
  • SCK → 13
  • Configurable:
  • CE → 8
  • CSN → 7
    */

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

void setup() {
Serial.begin(9600);
Serial.println( “Starting wireless…” );

// Setup
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)“clie1”);
Mirf.payload = sizeof(unsigned long);
Mirf.config();

// Read and print RF_SETUP
byte rf_setup = 0;
Mirf.readRegister( RF_SETUP, &rf_setup, sizeof(rf_setup) );
Serial.print( "rf_setup = " );
Serial.println( rf_setup, BIN );

Serial.println( “Wireless initialized!” );
}

void loop() {}

In file included from D:\arduino-0022\libraries\nRF24L01\mirf.c:29:
D:\arduino-0022\libraries\SPI/SPI.h:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘SPIClass’
D:\arduino-0022\libraries\SPI/SPI.h:53: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘SPI’
D:\arduino-0022\libraries\SPI/SPI.h:55: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘:’ token
D:\arduino-0022\libraries\SPI/SPI.h:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘:’ token
D:\arduino-0022\libraries\SPI/SPI.h:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘:’ token
D:\arduino-0022\libraries\nRF24L01\mirf.c:105: error: expected identifier or ‘(’ before ‘{’ token

I swear I won't have any hair left before I figure this all out... I just tried IDE 0022 on my wife's laptop running the Mirf example sketch and it worked... WTF??? Why won't it work on my desktop? SAME IDE, SAME board chosen, SAME library files...

Any thoughts?

I would think there is something wrong with your installation. I suggest removing all traces of all versions of the IDE, and starting again.

FINALLY!!!

So here's what I had to do: Windows or the Arduino IDE or a combination of both are caching some of the library code--because after a new install (and completely deleting or changing the folder name of the previous install), the Mirf library examples compiled! HOWEVER, if try to run even a bare minimum sketch with an nRF24L01 library that errors out, then the same Mirf examples WILL error out as well thereafter! Even after I completely shut down and restart the IDE. I have to completely delete and start over with a new installation and newly extracted library files for the Mirf library... some strange caching going on I guess...

Anyway, I wanted to at least report back to document this in the event someone else runs into the same strange phenomenon as I did. Thank you to all that have replied and helped guide me in the right direction. This is why I love open forums and software! So many incredibly knowledgeable and kind people willing to lend advice.