Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Another External Library Compile issue (Read 8854 times)
BrianB
Newbies
*
Offline



Posts: 6
Another External Library Compile issue
Dec 3rd, 2011 at 6:14pm
 
So what we have here is a simple Servo test app referencing the external servo library...

#include <C:\Program Files\arduino-0023\libraries\Servo\Servo.h>

Servo myServo;

int servoPin = 9;

void setup()
{
pinMode(servoPin,OUTPUT);
  myServo.attach(servoPin);

}

void loop()
{
     Serial.println("GO");
     for (int i=0; i<=180; i=i+5)
     {
           myServo.write(i);
           Serial.println(i);
           delay(100);
     }
}

When compiling I get the following....

Compiling 'ServoTest' for 'Arduino Uno'
ServoTest.cpp.o : In function `__static_initialization_and_destruction_0'
ServoTest.cpp : Servo()'
ServoTest.cpp.o : In function `loop'
ServoTest.cpp : write(int)'
ServoTest.cpp.o : In function `setup'
ServoTest.cpp : attach(int)'
: No such file
: No such file
Couldn't determine program size: C:\Program Files\arduino-0023\hardware\tools\avr\bin\avr-size: 'C:\Users\bbender\AppData\Local\VMicro\Arduino\Builds\ServoTest\uno\ServoTest.he
x': No such file
(0.6484375 secs)
Uploading to I/O board using 'COM6'
avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "C:\Program Files\arduino-0023\hardware\tools\avr\etc\avrdude.conf"

         Using Port            : \\.\COM6
         Using Programmer      : stk500v1
         Overriding Baud Rate  : 115200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv:
avrdude: Recv:
         AVR Part              : ATMEGA328P
         Chip Erase delay      : 9000 us
         PAGEL                 : PD7
         BS2                   : PC2
         RESET disposition     : dedicated
         RETRY pulse           : SCK
         serial program mode   : yes
         parallel program mode : yes
         Timeout               : 200
         StabDelay             : 100
         CmdexeDelay           : 25
         SyncLoops             : 32
         ByteDelay             : 0
         PollIndex             : 3
         PollValue             : 0x53
         Memory Detail         :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

... Out of space to paste but "avrdude done.  Thank you."
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10467
United Kingdom
Re: Another External Library Compile issue
Reply #1 - Dec 3rd, 2011 at 7:06pm
 
i notice you have included the servo lib manually. that can lead to mistakes. the best way to include libs is to use the "Add Arduino Library" option on the project menu.

i doubt the same souce compile in arduino?

the way the arduino compiler works is that it works out the lib paths from the includes. this is why when arduino (or vs) includes libs it does not add the full path.

in visual studio you simply add arduino library then click save to udpate the intellisense or just hit the compile button.

i just used your code but i removed the #include and let visual studio add it for me. it just added #include <Servo.h> and it compiled okay

it is important to use the menu item to add libs. because... if there is more than one .h file in the lib folder you will get an #include for each file. otherwise things might break Smiley
Back to top
« Last Edit: Dec 3rd, 2011 at 7:19pm by Visual Micro »  
WWW  
IP Logged
 
BrianB
Newbies
*
Offline



Posts: 6
Re: Another External Library Compile issue
Reply #2 - Dec 4th, 2011 at 2:56am
 
Thank you very much. that worked.

Newb to Arduino... Vet to C#

I'll get there
Back to top
 
 
IP Logged
 
BrianB
Newbies
*
Offline



Posts: 6
Re: Another External Library Compile issue
Reply #3 - Dec 4th, 2011 at 3:44am
 
Sorry, but how do you add custom libraries that are not in Arduino by default?

Do you have to manually copy them to the Arduino install path library folder?

Because I did that with the Ultrasonic.h library from here...

http://iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-m...

and added this code along with placing library under my C:\Program Files\arduino-1.0\libraries

VS along with intellisense recognized the library under the drop down menu after a reboot of the IDE and I added library the way you specified along with the following code...

#include <Ultrasonic.h>
Ultrasonic ultrasonic( 12, 13 );

void setup()
{
Serial.begin( 9600 );
}

void loop()
{
Serial.print(ultrasonic.Ranging(CM));
Serial.println("cm");

delay(1000);
}

Here is the compile error...

Compiling 'UltrasonicTest' for 'Arduino Uno'
UltrasonicTest.pde : In file included from
Ultrasonic.h : No such file or directory
Ultrasonic.cpp : No such file or directory
Ultrasonic.cpp : Ultrasonic(int, int)'
Ultrasonic.cpp : 'OUTPUT' was not declared in this scope
Ultrasonic.cpp : 'pinMode' was not declared in this scope
Ultrasonic.cpp : 'INPUT' was not declared in this scope
Ultrasonic.cpp : Timing()'
Ultrasonic.cpp : 'LOW' was not declared in this scope
Ultrasonic.cpp : 'digitalWrite' was not declared in this scope
Ultrasonic.cpp : 'delayMicroseconds' was not declared in this scope
Ultrasonic.cpp : 'HIGH' was not declared in this scope
Ultrasonic.cpp : 'pulseIn' was not declared in this scope
Error compiling

Thanks for your help.
Back to top
« Last Edit: Dec 4th, 2011 at 3:45am by BrianB »  
 
IP Logged
 
BrianB
Newbies
*
Offline



Posts: 6
Re: Another External Library Compile issue
Reply #4 - Dec 4th, 2011 at 3:55am
 
Further searching I found that since I added Arduino 1.0 I needed to modify the Ultrasonic library from...

#include "WProgram.h"

to..

#include "Arduino.h"

Most compile errors went away but these remain...

Compiling 'UltrasonicTest' for 'Arduino Uno'
Ultrasonic.pde : In file included from
Ultrasonic.h : No such file or directory
Ultrasonic.cpp : In file included from
Ultrasonic.h : No such file or directory
Error compiling
Back to top
 
 
IP Logged
 
BrianB
Newbies
*
Offline



Posts: 6
Re: Another External Library Compile issue
Reply #5 - Dec 4th, 2011 at 4:16am
 
Disregard....

Forgot to change reference in Ultrasonic.h as well as .cpp

Genius!

All is well. Baby steps.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10467
United Kingdom
Re: Another External Library Compile issue
Reply #6 - Dec 4th, 2011 at 6:31pm
 
yep, seems kind of dumb to have changed wprogram.h to arduino.h. so much old code uses it. just as dumb as changing the arduino.cc forum address Smiley it kills backward compatibility.

i'm pleased you got it working.

you can also create a "libraries" folder under your sketch book folder. for example "document\arduino\libraries".

putting libs under the sketchbook causes them to show on the "Add Arduino Library>User" menu instead of "Add Arduino Library>Core"
Back to top
 
WWW  
IP Logged
 
BrianB
Newbies
*
Offline



Posts: 6
Re: Another External Library Compile issue
Reply #7 - Dec 5th, 2011 at 5:04am
 
Nice! Very helpful. Thanks!
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print