Go Down

Topic: Arduino/Genuino UNO R3 Board does not compile (Read 615 times) previous topic - next topic

VelariFox

When checking sketches, in most cases an error is generated. Here is the error text:

 Board:"Arduino/Uno Genuino" operating system Windows 10,Tried version Ardyino.IDE 1.8.7, 1.8.6, 1.8.5, 1.8.4, 1.8.3, 1.8.2, 1.8.1, 1.8.0, 1.6.13, 1.6.12, 1.6.9.

C:\Users\Р°R°R\Desktop\Tehnic\Robototehnika\Programs\Remont\AFMotor_ConstantSpeed\AFMotor_ConstantSpeed.ino:10:26: fatal error: AccelStepper.h: No such file or directory

compilation terminated.

exit status 1
Compilation error for Arduino/Genuino Uno Board.

This report will have more information with
enabled file -> Settings ->
"Show verbose output during compilation"

Please help the layman.

pert

When you see a "No such file or directory" error it almost always means you need to install the library that contains the missing file.

Often the code you're compiling will come with documentation (either a comment or separate document) that tells you where to get the library dependencies.

In other cases the author of the code will not have been so kind and you'll need to go on a hunt for the missing library.

A good place to start is the Arduino IDE's Library Manager:
  • Sketch > Include Library > Manage Libraries...
  • In the "Filter your search..." box, type some keywords you have gleaned from the missing file name.
  • Scroll through the results for the right library. Click on it.
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".
  • Try compiling your code again.


If you have no luck in Library Manager then load up your favorite search engine and do a search for the missing filename. You will often get multiple results. If you have a lot of results you might add "arduino" as an additional search keyword. I will usually prefer results on github.com since that is where most Arduino libraries are hosted and downloading from there is fast and easy. In some cases there will be multiple libraries that contain the given filename and you'll need to do some evaluation to determine which seems the most appropriate, then try it out. After downloading the library you found you'll need to install it. This requires a different process than the Library Manager installation. You will find instructions here:

VelariFox

Thank you for your advice. But now I have a new problem. Here is the error text:
 Arduino: 1.6.9 (Windows 10), Board:"Arduino/Genuino Uno"

C:\Users\аап\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:7:22: fatal error: WProgram.h: No such file or directory

 #include "WProgram.h"

                      ^

compilation terminated.

Several libraries found for "AFMotor.h"
 Used By: C:\Users\аап\Documents\Arduino\libraries\AFMotor
Not used: C:\Users\аап\Documents\Arduino\libraries\Adafruit-Motor-Shield-library-master
exit status 1
Compilation error for Arduino/Arduino Uno Board.

This report will have more information with
enabled file -> Settings ->
"Show verbose output during compilation".
 Can you help?

pert

This is a situation where you get the same type of error as before, but it's not solved by installing a library. Here's the solution:

Open C:\Users\аап\Documents\Arduino\libraries\AFMotor\AFMotor.cpp in a text editor

Change line 7 from:
Code: [Select]
#include "WProgram.h"
to:
Code: [Select]
#include "Arduino.h"

Save the file.



However, you should be aware that this error indicates the library you installed at C:\Users\аап\Documents\Arduino\libraries\AFMotor is extremely outdated. You might want to look around to see if you can find a newer version. In fact, a helpful informational message from the Arduino IDE indicates you might already have a newer version installed:
Code: [Select]
Several libraries found for "AFMotor.h"
 Used By: C:\Users\аап\Documents\Arduino\libraries\AFMotor
Not used: C:\Users\аап\Documents\Arduino\libraries\Adafruit-Motor-Shield-library-master


VelariFox

Thanks, but now I have another problem. Here is the error text: Arduino: 1.6.9 (Windows 10), Board:"Arduino/Genuino Uno"

C:\Users\Р°R°R\Desktop\Tehnic\Robototehnika\Programs\Remont\AFMotor_ConstantSpeed\AFMotor_ConstantSpeed.ino: In function 'void loop()':

AFMotor_ConstantSpeed:57: error: expected '}' at end of input

AFMotor_ConstantSpeed:57: error: expected '}' at end of input

exit status 1
expected '}' at end of input

This report will have more information with
enabled file -> Settings ->
"Show verbose output during compilation".
Help me?

pert

Please post your full sketch.

If possible, you should always post code directly in the forum thread as text using code tags:
  • Do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code. This will make it easier for you to spot bugs and make it easier for us to read.
  • In the Arduino IDE or Arduino Web Editor, click on the window that contains your sketch code.
  • Press "Ctrl + A". This will select all the text.
  • Press "Ctrl + C". This will copy the selected text to the clipboard.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the sketch between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
  • Repeat the above process if your sketch has multiple tabs.


This will make it easy for anyone to look at it, which will increase the likelihood of you getting help.

If the sketch is longer than the 9000 characters maximum allowed by the forum, then it's OK to add it as an attachment. After clicking the "Reply" button, you will see an "Attachments and other settings" link.

When your code requires a library that's not included with the Arduino IDE please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

VelariFox

Okay here is the sketch code:

#include <AccelStepper.h>

#include <Arduino.h>




#include <AFMotor.h> // connect library for shield

AF_DCMotor motor1(1); // connect motor to M1 terminal block

AF_DCMotor motor2(2); // connect motor to m2 terminal block



int val; // free memory in the controller



void setup() {



  Serial.begin(9600);

  motor1.setSpeed(250); // set the maximum speed of the motor

  motor1.run(RELEASE); // stop the motor

  motor2.setSpeed(250); // set the maximum speed of the motor

  motor2.run(RELEASE); // stop the motor

}



void loop() {



  if (Serial.available()) // check if any commands are received

  {

    val = Serial.read();



    if (val == 'f') { // let's go ahead

      motor1.run(FORWARD);

      motor1.setSpeed(250);

      motor2.run(FORWARD);

      motor2.setSpeed(250);

    }



    if (val == 'b') { // let's go back

      motor1.run(BACKWARD);

      motor1.setSpeed(200);

      motor2.run(BACKWARD);

      motor2.setSpeed(200);

    }



    if (val == 's') { // stop

      motor1.run(RELEASE);

      motor2.run(RELEASE);

    }



    if (val == 'l') { // turn left

      motor1.run(FORWARD);

      motor1.setSpeed(100);

      motor2.run(BACKWARD);

      motor2.setSpeed(250);

    }



    if (val == 'r') { // turn right

      motor1.run(BACKWARD);

      motor1.setSpeed(250);

      motor2.run(FORWARD);

      motor2.setSpeed(100);

    }

sterretje

#7
Apr 14, 2019, 08:21 am Last Edit: Apr 14, 2019, 08:22 am by sterretje
Please read How to use this forum - please read, specifically point #7 how to post code.

It looks like you're missing some } at the end of the code; one to close the if (Serial.available()) and one to close loop().

If you use menu -> tools -> auto format in the IDE, the last } of the code should be at the beginning of a line.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

VelariFox

Okay here is the edit code of the sketch:
Code: [Select]
#include <AccelStepper.h>
#include <Arduino.h>


#include <AFMotor.h> // connect library for shield
AF_DCMotor motor1(1); // connect motor to M1 terminal block
AF_DCMotor motor2(2); // connect motor to m2 terminal block

int val; // free memory in the controller

void setup() {

  Serial.begin(9600);
  motor1.setSpeed(250); // set the maximum speed of the motor
  motor1.run(RELEASE); // stop the motor
  motor2.setSpeed(250); // set the maximum speed of the motor
  motor2.run(RELEASE); // stop the motor
}

void loop() {

  if (Serial.available()) // check if any commands are received
  {
    val = Serial.read();

    if (val == 'f') { // let's go ahead
      motor1.run(FORWARD);
      motor1.setSpeed(250);
      motor2.run(FORWARD);
      motor2.setSpeed(250);
    }

    if (val == 'b') { // let's go back
      motor1.run(BACKWARD);
      motor1.setSpeed(200);
      motor2.run(BACKWARD);
      motor2.setSpeed(200);
    }

    if (val == 's') { // stop
      motor1.run(RELEASE);
      motor2.run(RELEASE);
    }

    if (val == 'l') { // turn left
      motor1.run(FORWARD);
      motor1.setSpeed(100);
      motor2.run(BACKWARD);
      motor2.setSpeed(250);
    }

    if (val == 'r') { // turn right
      motor1.run(BACKWARD);
      motor1.setSpeed(250);
      motor2.run(FORWARD);
      motor2.setSpeed(100);
    }

pert

You're still missing those closing braces sterretje told you about. If you look at the indentation that resulted from the auto format, it makes this clear.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

Every { in your code must have a matching }.

ywesla77

please fix this.. i cant compile/verify anything (sketches/examples)

Code: [Select]
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\berin\Documents\ArduinoData\packages -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\berin\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\berin\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10809 -build-path C:\Users\berin\AppData\Local\Temp\arduino_build_120581 -warnings=none -build-cache C:\Users\berin\AppData\Local\Temp\arduino_cache_598405 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -verbose C:\Users\berin\Documents\Arduino\Blink\Blink.ino
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\arduino-builder -compile -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\berin\Documents\ArduinoData\packages -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\berin\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\berin\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10809 -build-path C:\Users\berin\AppData\Local\Temp\arduino_build_120581 -warnings=none -build-cache C:\Users\berin\AppData\Local\Temp\arduino_cache_598405 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr -verbose C:\Users\berin\Documents\Arduino\Blink\Blink.ino
Error compiling for board Arduino/Genuino Uno.

pert

@ywesla77 please stop hijacking threads.

DrAzzy

ywesla77, don't post in threads about unrelated problems. That's a very strange error - does it happen with the desktop version of the IDE? Windows store version of the Arduino IDE (as well as most other things) seems to have a high incidence of issues that don't reproduce for others and don't make sense.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

VelariFox

I changed the version of the program and now I have another error. Here is its text:

 Arduino: 1.6.13 (Windows 10), Board:"Arduino/Arduino Uno"

C:\Users\аап\Documents\Arduino\libraries\AFMotor\AFMotor.cpp:7:22: fatal error: WProgram.h: No such file or directory

 #include "WProgram.h"

                      ^

compilation terminated.

exit status 1
Compilation error for Arduino/Arduino Uno Board.

This report will have more information with
enabled file -> Settings ->
"Show verbose output during compilation"

pert

I changed the version of the program and now I have another error.
I already told you how to fix that a week ago:
This is a situation where you get the same type of error as before, but it's not solved by installing a library. Here's the solution:

Open C:\Users\аап\Documents\Arduino\libraries\AFMotor\AFMotor.cpp in a text editor

Change line 7 from:
Code: [Select]
#include "WProgram.h"
to:
Code: [Select]
#include "Arduino.h"

Save the file.



However, you should be aware that this error indicates the library you installed at C:\Users\аап\Documents\Arduino\libraries\AFMotor is extremely outdated. You might want to look around to see if you can find a newer version. In fact, a helpful informational message from the Arduino IDE indicates you might already have a newer version installed:

Go Up