No such file or directory. Compilation terminated.

I'm working on an OBDuino project and keep getting the Fatal Error: "No such file or directory
compilation terminated." The file in question is indeed in the appropriate library. I can see it with Windows Explorer and can open it in Notepad. I'd sure like to fire up my hardware but until I can upload the sketch, I'm dead in the water.

Anybody have any suggestions?

Arduino: 1.6.0 (Windows 7), Board: "Arduino Uno"

Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI

Using library LiquidCrystal in folder: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal

C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10600 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src C:\Users\Garage\AppData\Local\Temp\build390135135192985775.tmp\obduino32K_with_buttons.cpp -o C:\Users\Garage\AppData\Local\Temp\build390135135192985775.tmp\obduino32K_with_buttons.cpp.o

obduino32K_with_buttons.ino:2:21: fatal error: MCP2515.h: No such file or directory
compilation terminated.
Error compiling.

Running Arduino IDE 1.6 on Win7 Ultimate (64 bit).

You need to post your code, not just the error message.

Welcome to the Forum. You may also want to read Nick's two posts at the top of this Forum, as they will likely help us help you, especially when posting your code.

I had a similar error with the LiquidCrystal library. I found that I had a LiquidCrystal library directory in both the Arduino program directory and in my /Documents/Arduino/libraries directory. I renamed the one in my userdir so that it would not be found. Restarted the Arduino IDE and all worked then.

Hope this will work for you.

All the best.

Welcome to forum JetDriver.

If you see the error ;

fatal error: MCP2515.h: No such file or directory

That means in your code you not included the library.

Inorder to get help here. You need paste ur code & library file. If you copied from some linkor forum. share us those links

That means in your code you not included the library.

Nonsense, as usual.

That message is triggered by the fact that you HAVE tried to include a library (that has not been properly installed).

I have attached the code I’m using because it exceeded the 9000 character maximum allowed for messages. The two zipped libraries, MCP2515 and OBDIICanbus, were placed on my desktop and installed using the IDE’s “Import Library|Add a Library” function. The two unzipped folders do appear in “My Doucuments/Arduino/libraries”.

The error code is repeated below.

I’m stumped. Any assitance would be greatly appreciated. Thanks!

Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library LiquidCrystal in folder: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal

C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10601 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src C:\Users\Garage\AppData\Local\Temp\build6031344095205737667.tmp\obduino32K_with_buttons.cpp -o C:\Users\Garage\AppData\Local\Temp\build6031344095205737667.tmp\obduino32K_with_buttons.cpp.o
obduino32K_with_buttons.ino:2:21: fatal error: MCP2515.h: No such file or directory
compilation terminated.
Error compiling.

obduino32K_with_buttons.ino (101 KB)

please share us link where you downloaded the

#include <MCP2515.h>
#include <OBDIICanbus.h>

both these library

Here's the link for the project files:

Thanks for taking a look at it.

I clicked your link. It downloaded a zip file. That zip file contained two other zip files. I opened each of them, and drug the folder that each contained into my Arduino\libraries folder.

I clicked on the file you attached, and it opened in Notepad++. Ctrl-A, Ctrl-C, and Ctrl-V in the Arduino IDE. I got just one "error" message:

Binary sketch size: 27,764 bytes (of a 258,048 byte maximum)

So, I'll repeat my earlier statement. You have NOT properly download/installed the libraries.

Well, of course, you were correct. I had the libraries in question in sub-sub directories. Once I fixed that and ran “Verify,” I got a huge number of error codes that have nothing to do with finding libraries. How come you didn’t?

Could it be because this sketch was written 5 years ago using whatever the current version of the IDE was at that time and I’m using v1.6.1? In case you’re interested, here’s a link.

Thanks for straightening me out re the libraries.

error codes.txt (21.8 KB)

Try IDE 1.5.8 or something like that. The 1.6.x ones changed things around a bit.

Thanks for the suggestion, Nick, but running the sketch with IDE 1.5.8 generated the same error codes. I'll keep plugging away at it. Ciao!

Probably debris left over in sketchbook from 1.0.6? Check over that - stuff in there left over from old versions has been causing problems like this for people since they began trying to ram the 1.6.x versions down our throats.

I try to connect with nodeMCU ESP8266 to AWS IOT sever by using MQTT/Websockets, but there is code which i wrote in Arduino IDE is showing library missing errors every time. For your convenience i’ll post all the code i wrote and wrrors also.
#include <Arduino.h>
#include <Stream.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include “sha256.h”
#include “Utils.h”
#include “AWSClient2.h”

#include <Hash.h>
#include <WebSocketsClient.h>

#include <SPI.h>
#include <IPStack.h>
#include <Countdown.h>
#include <MQTTClient.h>

//AWS MQTT Websocket
#include “Client.h”
#include “AWSWebSocketClient.h”
#include “CircularByteBuffer.h”

//AWS IOT config, change these:
char wifi_ssid = “iPRO”;
char wifi_password = “!Pro#123”;
char aws_endpoint = “”;
char aws_key = “AKIAIMPS76OD7YRVXZUQ”;
char aws_secret = “W2yC0k0nesTufzKXN3sebNtnETYvJqwHjAk8K4JF”;
char aws_region = “us-east-1”;
const char* aws_topic = “$aws/things/your-device/shadow/update”;
int port = 443;

//MQTT config
const int maxMQTTpackageSize = 512;
const int maxMQTTMessageHandlers = 1;

ESP8266WiFiMulti WiFiMulti;

AWSWebSocketClient awsWSclient(1000);

IPStack ipstack(awsWSclient);
MQTT::Client<IPStack, Countdown, maxMQTTpackageSize, maxMQTTMessageHandlers> *client = NULL;

//# of connections
long connection = 0;

//generate random mqtt clientID
char* generateClientID () {
char* cID = new char23;
for (int i=0; i<22; i+=1)
cID*=(char)random(1, 256);*

  • return cID;*
    //count messages arrived
    int arrivedcount = 0;
    //callback to handle mqtt messages
    void messageArrived(MQTT::MessageData& md)
  • MQTT::Message &message = md.message;*
  • Serial.print("Message ");*
  • Serial.print(++arrivedcount);*
  • Serial.print(" arrived: qos ");*
  • Serial.print(message.qos);*
  • Serial.print(", retained ");*
  • Serial.print(message.retained);*
  • Serial.print(", dup ");*
  • Serial.print(message.dup);*
  • Serial.print(", packetid ");*
  • Serial.println(;*
  • Serial.print("Payload ");*
    _ char* msg = new charmessage.payloadlen+1;_
  • memcpy (msg,message.payload,message.payloadlen);*
  • Serial.println(msg);*
  • delete msg;*
    //connects to websocket layer and mqtt layer
    bool connect () {
  • if (client == NULL) {*
  • client = new MQTT::Client<IPStack, Countdown, maxMQTTpackageSize, maxMQTTMessageHandlers>(ipstack);*
  • } else {*
  • if (client->isConnected ()) { *
  • client->disconnect ();*
  • } *
  • delete client;*
  • client = new MQTT::Client<IPStack, Countdown, maxMQTTpackageSize, maxMQTTMessageHandlers>(ipstack);*
  • }*
  • //delay is not necessary… it just help us to get a “trustful” heap space value*
  • delay (1000);*
  • Serial.print (millis ());*
  • Serial.print (" - conn: ");*
  • Serial.print (++connection);*
  • Serial.print (" - (");*
  • Serial.print (ESP.getFreeHeap ());*
  • Serial.println (")");*
  • int rc = ipstack.connect(aws_endpoint, port);*
  • if (rc != 1)*
  • {*
  • Serial.println(“error connection to the websocket server”);*
  • return false;*
  • } else {*
  • Serial.println(“websocket layer connected”);*
  • }*
  • Serial.println(“MQTT connecting”);*
  • MQTTPacket_connectData data = MQTTPacket_connectData_initializer;*
  • data.MQTTVersion = 3;*
    _ char* clientID = generateClientID ();_
  • data.clientID.cstring = clientID;*
  • rc = client->connect(data);*
  • delete clientID;*
  • if (rc != 0)*
  • {*
  • Serial.print(“error connection to MQTT server”);*
  • Serial.println(rc);*
  • return false;*
  • }*
  • Serial.println(“MQTT connected”);*
  • return true;*
    //subscribe to a mqtt topic
    void subscribe () {
  • //subscript to a topic*
  • int rc = client->subscribe(aws_topic, MQTT::QOS0, messageArrived);*
  • if (rc != 0) {*
  • Serial.print("rc from MQTT subscribe is ");*
  • Serial.println(rc);*
  • return;*
  • }*
  • Serial.println(“MQTT subscribed”);*
    //send a message to a mqtt topic
    void sendmessage () {
  • //send a message*
  • MQTT::Message message;*
  • char buf[100];*
  • strcpy(buf, “{“state”:{“reported”:{“on”: false}, “desired”:{“on”: false}}}”);*
  • message.qos = MQTT::QOS0;*
  • message.retained = false;*
  • message.dup = false;*
    _ message.payload = (void*)buf;_
  • message.payloadlen = strlen(buf)+1;*
  • int rc = client->publish(aws_topic, message);*
    void setup() {
  • Serial.begin (115200);*
  • delay (2000);*
  • Serial.setDebugOutput(1);*
  • //fill with ssid and wifi password*
  • WiFiMulti.addAP(wifi_ssid, wifi_password);*
  • Serial.println (“connecting to wifi”);*
  • while( != WL_CONNECTED) {*
  • delay(100);*
  • Serial.print (".");*
  • }*
  • Serial.println ("\nconnected");*
  • //fill AWS parameters *
  • awsWSclient.setAWSRegion(aws_region);*
  • awsWSclient.setAWSDomain(aws_endpoint);*
  • awsWSclient.setAWSKeyID(aws_key);*
  • awsWSclient.setAWSSecretKey(aws_secret);*
  • awsWSclient.setUseSSL(true);*
  • if (connect ()){*
  • subscribe ();*
  • sendmessage ();*
  • }*
    void loop() {
  • //keep the mqtt up and running*
  • if (awsWSclient.connected ()) { *
  • client->yield();*
  • } else {*
  • //handle reconnection*
  • if (connect ()){*
  • subscribe (); *
  • }*
  • }*
    *} *
    Error is …
    fatal error: platforms.h: No such file or directory
    #include “platforms.h” (xxxxxxxxx.h)
  • ^*
    compilation terminated.
    Thanq you

Is that the whole error message ?
I rather think not.

Also, because you did not put code tags round your code most of it is in italics due to your use of an i being interpreted as an HTML command to change to italics.

It won't be the source of your error, but I hope they're not your real Amazon AWS login details.

This is a old issue but I ran into this issue myself and wanted to perhaps save someone a headache.

When you encounter this issue check how the includes are formatted as shown below.

// search the local path for the header
#include “MCP2515.h”

// search the library path for the header
#include <MCP2515.h>

C++ is loaded with nuance (pointers/references, data types, header vs. cpp files) and this is another one of them. When I switch from MicroPython back to Arduino .ino files I need to sorta turn by brain back on.

It is my understanding that later versions of the IDE have changed the library search path so that

#include "MCP2515.h"

now means “use the library file in the sketch directory if it is present, otherwise look in the libraries folder in the sketchbook folder else look in the core libraries folder”

It may actually be more complicated, but that is how it works in essence.

The result is that

#include "bbMotor.h"

works when bbMotor.h is not in the sketch folder but is in the user libraries folder

Most likely, the problem is that you're using a relative file path to open the file, but the current working directory isn't set to what you think it is.

It's a common misconception that relative paths are relative to the location of the python script, but this is untrue. Relative file paths are always relative to the current working directory, and the current working directory doesn't have to be the location of your python script.

You have three options:

Use an absolute path to open the file.
Generate the path to the file relative to your python script.
Change the current working directory before opening the file