Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Compilation Error. I don't understand why I get it (Read 15942 times)
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Compilation Error. I don't understand why I get it
Dec 14th, 2013 at 4:36pm
Print Post  
I'm Trying to use this OneWire library
http://www.pjrc.com/teensy/td_libs_OneWire.html
so I wrote this simple test code
Code
Select All
#include <OneWire.h>
void setup()
{

  /* add setup code here */

}

void loop()
{

  /* add main program code here */

}
 



I get this result from Micro Build

Compiling 'Test' for 'Arduino Uno'
BSeries.cpp : No such file or directory
BSeries.cpp : : In member function 'virtual float BSeries::getTemperature(NewOneWire*)':
BSeries.cpp : 'byte' was not declared in this scope
BSeries.cpp : expected `;' before 'lowByte'
BSeries.cpp : expected `;' before 'highByte'
BSeries.cpp : 'highByte' was not declared in this scope
BSeries.cpp : 'lowByte' was not declared in this scope
DallasTemperature.cpp : No such file or directory
DallasTemperature.cpp : : In member function 'void DallasTemperature::beginCommunication()':
DallasTemperature.cpp : 'delay' was not declared in this scope
DallasTemperature.cpp : : In member function 'float DallasTemperature::getTemperature()':
DallasTemperature.cpp : 'byte' was not declared in this scope
DallasTemperature.cpp : expected `;' before 'lowByte'
DallasTemperature.cpp : expected `;' before 'highByte'
DallasTemperature.cpp : 'highByte' was not declared in this scope
DallasTemperature.cpp : 'lowByte' was not declared in this scope
NewOneWire.cpp : No such file or directory
OneWire.cpp : No such file or directory
OneWire.cpp : : In constructor 'OneWire:ShockedneWire(uint8_t)':
OneWire.cpp : 'digitalPinToPort' was not declared in this scope
OneWire.cpp : 'digitalPinToBitMask' was not declared in this scope
OneWire.cpp : 'portOutputRegister' was not declared in this scope
OneWire.cpp : 'portInputRegister' was not declared in this scope
OneWire.cpp : 'portModeRegister' was not declared in this scope
OneWire.cpp : : In member function 'uint8_t OneWire::reset()':
OneWire.cpp : 'INPUT' was not declared in this scope
OneWire.cpp : 'pinMode' was not declared in this scope
OneWire.cpp : 'delayMicroseconds' was not declared in this scope
OneWire.cpp : 'digitalRead' was not declared in this scope
OneWire.cpp : 'digitalWrite' was not declared in this scope
OneWire.cpp : 'OUTPUT' was not declared in this scope
OneWire.cpp : 'delayMicroseconds' was not declared in this scope
OneWire.cpp : : In member function 'void OneWire::write_bit(uint8_t)':
OneWire.cpp : 'delayMicroseconds' was not declared in this scope
OneWire.cpp : : In member function 'uint8_t OneWire::read_bit()':
OneWire.cpp : 'delayMicroseconds' was not declared in this scope
OneWire.cpp : : In member function 'void OneWire::write(uint8_t, uint8_t)':
OneWire.cpp : 'INPUT' was not declared in this scope
OneWire.cpp : 'pinMode' was not declared in this scope
OneWire.cpp : 'digitalWrite' was not declared in this scope
OneWire.cpp : : In member function 'void OneWire::depower()':
OneWire.cpp : 'INPUT' was not declared in this scope
OneWire.cpp : 'pinMode' was not declared in this scope
S20Series.cpp : No such file or directory
S20Series.cpp : : In member function 'virtual float S20Series::getTemperature(NewOneWire*)':
S20Series.cpp : 'byte' was not declared in this scope
S20Series.cpp : expected `;' before 'lowByte'
S20Series.cpp : expected `;' before 'highByte'
S20Series.cpp : 'highByte' was not declared in this scope
S20Series.cpp : 'lowByte' was not declared in this scope
StratBase.cpp : No such file or directory
Error compiling

This code compiles from the standard Arduino IDE but not with Visual Micro. I have checked the content of OneWire.h and see that Bseries.cpp is nowhere referenced in the code.
Why does code that is not part of the program cause compilation errors?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation Error. I don't understand why I get it
Reply #1 - Dec 15th, 2013 at 3:40pm
Print Post  
Hi Jan,

Please confirm which board you are using and also where you have located the oneWire library

Thanks
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Compilation Error. I don't understand why I get it
Reply #2 - Dec 15th, 2013 at 5:21pm
Print Post  
Tim@Visual Micro wrote on Dec 15th, 2013 at 3:40pm:
Hi Jan,

Please confirm which board you are using and also where you have located the oneWire library

Thanks


In this case I was using a Arduino Uno board. One of the computer has the library at
D:\Users\Jan\Documents\Arduino\libraries
Have encountered this problem on several computers.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation Error. I don't understand why I get it
Reply #3 - Dec 15th, 2013 at 6:37pm
Print Post  
Thanks for the info ...

1)

I just compiled your example using the library link you provided using both a free install of Arduino 1.0.5 and of Arduino 1.5.3.

If you switch on "Tools>options>visual micro>compiler> verbose=True" then click "Build>Clean" then run the compile again we will see where the duplicate library or library containing duplicate files is located.

2)

It's possible that Visual Micro is searching for libraries in a different order to the Arduino Ide and that you have an older  library somewhere that contains a OneWire.h/cpp (that also contains links to other invalid libraries). 

There are two locations that will be searched for Arduino libraries. The one you know about and the ArduinoIde/Libraries folder.

Please remove the library that contains a OneWire.cpp/.h other than the OneWire library itself.

After doing so, if the Ide is open, please click "Tools>Visual Micro>Reload Toolchains"

More ..

It is possible you have an older version of a lib such as the DallasTemperature lib installed with a conflicting cpp/h file. 

Notice that with Arduino libraries we are not allowed to specify a folder name in the #include. It's an Arduino rule. 

Therefore libs can not contain source files with the same name as a file in another library. In a future Visual Micro version, changing the search path used to resolve libs might fix this particular issue (as with the Arduino ide) but it's prone to break as is the Arduino Ide based on duplicate lib source names.
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Compilation Error. I don't understand why I get it
Reply #4 - Dec 15th, 2013 at 7:06pm
Print Post  
I do have folders with name DallasTemperature. Is that the problem ? It's referenced in the output after follwing your suggestions,

Board Properties
name=Arduino Uno
upload.protocol=arduino
upload.maximum_size=32256
upload.speed=115200
bootloader.low_fuses=0xff
bootloader.high_fuses=0xde
bootloader.extended_fuses=0x05
bootloader.path=optiboot
bootloader.file=optiboot_atmega328.hex
bootloader.unlock_bits=0x3F
bootloader.lock_bits=0x0F
build.mcu=atmega328p
build.f_cpu=16000000L
build.core=arduino
build.variant=standard
runtime.ide.path=F:\Arduino
build.system.path=F:\Arduino\hardware\arduino\system
software=ARDUINO
runtime.ide.version=105
vm.core.include=arduino.h
vm.boardsource.path=F:\Arduino\hardware\arduino
vm.boardsource.name=boards.txt
vm.platformname.name=

Compiling 'Entrad' for 'Arduino Uno'
Build folder: file://C:\Users\Jan\AppData\Local\VMicro\Arduino\Builds\Entrad\uno
SketchLibFolders
are\tools\avr\avr\;f:\arduino\hardware\tools\avr\lib\gcc\avr\4.3.2\include\;
Summary: Header=1 Prototypes=3 Imports=1
Additional Defines: VISUALMICRO_COMPILER_VER=1;
Architecture Tools: F:\Arduino\hardware\tools\avr\bin\
GCC: 4.3.2
Sketchbook: file://C:\Users\Jan\Documents\Arduino
F:\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -Wall -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I"F:\Arduino\hardware\arduino\cores\arduino" -I"F:\Arduino\hardware\arduino\variants\standard" -I"C:\Users\Jan\Documents\Arduino\libraries\DallasTemperature" -o "C:\Users\Jan\AppData\Local\VMicro\Arduino\Builds\Entrad\uno\Entrad.cpp.o"  "C:\Users\Jan\AppData\Local\VMicro\Arduino\Builds\Entrad\uno\Entrad.cpp"  -DVISUALMICRO_COMPILER_VER=1
F:\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -Wall -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I"F:\Arduino\hardware\arduino\cores\arduino" -I"F:\Arduino\hardware\arduino\variants\standard" -I"C:\Users\Jan\Documents\Arduino\libraries\DallasTemperature" -o Series.cpp.o"  "C:\Users\Jan\Documents\Arduino\libraries\DallasTemperature\BSeries.cpp"  -DVISUALMICRO_COMPILER_VER=1
Arduino.h : In file included from
BSeries.cpp : from
WString.h : declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
WString.h : previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
WString.h : 'StringSumHelper& operator+(const StringSumHelper&, const char*)' is already a friend of class 'String'
WString.h : declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
WString.h : previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
WString.h : 'StringSumHelper& operator+(const StringSumHelper&, char)' is already a friend of class 'String'
WString.h : declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
WString.h : previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
WString.h : 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' is already a friend of class 'String'
WString.h : declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
WString.h : previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
WString.h : 'StringSumHelper& operator+(const StringSumHelper&, int)' is already a friend of class 'String'
WString.h : declarat
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation Error. I don't understand why I get it
Reply #5 - Dec 15th, 2013 at 7:11pm
Print Post  
I think if you delete the OneWire.h from C:\Users\Jan\Documents\Arduino\libraries\DallasTemperature and click "Reload Toolchain" it should fix the problem.

Thanks
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Compilation Error. I don't understand why I get it
Reply #6 - Dec 15th, 2013 at 7:47pm
Print Post  
Tim@Visual Micro wrote on Dec 15th, 2013 at 7:11pm:
I think if you delete the OneWire.h from C:\Users\Jan\Documents\Arduino\libraries\DallasTemperature and click "Reload Toolchain" it should fix the problem. 

Thanks


It did on one of my computers. The second still gives compilation error with output below. Here I have removed duplicates of the library and deleted the suggested OneWire.h 

Compiling 'SimpleTermometer' for 'Arduino Uno'
Build folder: file:///C:/Users/JAN/AppData/Local/VMicro/Arduino/Builds/SimpleTermometer/uno
SketchLibFolders
;c:\arduino\hardware\tools\avr\lib\gcc\avr\4.3.2\include\;
Summary: Header=1 Prototypes=5 Imports=2
Additional Defines: VISUALMICRO_COMPILER_VER=1;
Architecture Tools: C:\Arduino\hardware\tools\avr\bin\
GCC: 4.3.2
Sketchbook: file:///C:/Users/JAN/Documents
C:\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -Wall -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I"C:\Arduino\hardware\arduino\cores\arduino" -I"C:\Arduino\hardware\arduino\variants\standard" -I"C:\Arduino\libraries\LiquidCrystal" -I"C:\Users\JAN\Documents\libraries\DallasTemperature" -o mometer.cpp.o"  mometer.cpp"  -DVISUALMICRO_COMPILER_VER=1
SimpleTermometer.ino : : In function 'void setup()':
SimpleTermometer.ino : Warning: only initialized variables can be placed into program memory area
SimpleTermometer.ino : Warning: only initialized variables can be placed into program memory area
SimpleTermometer.ino : : In function 'void loop()':
SimpleTermometer.ino : Warning: unused variable 'buffer'
SimpleTermometer.ino : : In function 'int read_LCD_buttons()':
SimpleTermometer.ino : control reaches end of non-void function
C:\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -Wall -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I"C:\Arduino\hardware\arduino\cores\arduino" -I"C:\Arduino\hardware\arduino\variants\standard" -I"C:\Arduino\libraries\LiquidCrystal" -I"C:\Users\JAN\Documents\libraries\DallasTemperature" -o stal\LiquidCrystal.cpp.o"  "C:\Arduino\libraries\LiquidCrystal\LiquidCrystal.cpp"  -DVISUALMICRO_COMPILER_VER=1
C:\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -Wall -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I"C:\Arduino\hardware\arduino\cores\arduino" -I"C:\Arduino\hardware\arduino\variants\standard" -I"C:\Arduino\libraries\LiquidCrystal" -I"C:\Users\JAN\Documents\libraries\DallasTemperature" -o perature\BSeries.cpp.o"  "C:\Users\JAN\Documents\libraries\DallasTemperature\BSeries.cpp"  -DVISUALMICRO_COMPILER_VER=1
BSeries.cpp : No such file or directory
BSeries.cpp : : In member function 'virtual float BSeries::getTemperature(NewOneWire*)':
BSeries.cpp : 'byte' was not declared in this scope
BSeries.cpp : expected `;' before 'lowByte'
BSeries.cpp : expected `;' before 'highByte'
BSeries.cpp : 'highByte' was not declared in this scope
BSeries.cpp : 'lowByte' was not declared in this scope
C:\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -Wall -mmcu=atmega328p -DF_CPU=1
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation Error. I don't understand why I get it
Reply #7 - Dec 15th, 2013 at 7:55pm
Print Post  
Ok try clicking "Build>Clean Solution" then compile. Was the Ide already open when you removed the file from the 2nd machine? if so did you click "Tools>Visual Micro>Reload toolchain"?

If it is still a problem then remove the DallasTemerature library folder to prove it works. Then email the contents of the sketch folder to info [at] visualmicro.com.

We can put the lib back again once we prove the problem is resolved without it.
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Compilation Error. I don't understand why I get it
Reply #8 - Dec 15th, 2013 at 10:40pm
Print Post  
Tim@Visual Micro wrote on Dec 15th, 2013 at 7:55pm:
Ok try clicking "Build>Clean Solution" then compile. Was the Ide already open when you removed the file from the 2nd machine? if so did you click "Tools>Visual Micro>Reload toolchain"?

If it is still a problem then remove the DallasTemerature library folder to prove it works. Then email the contents of the sketch folder to info [at] visualmicro.com.

We can put the lib back again once we prove the problem is resolved without it.


Removing DallasTemperature folder didn't help and I reloaded the toolchain and cleaned the solution. I have mailed my sketch folder as instructed.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation Error. I don't understand why I get it
Reply #9 - Dec 16th, 2013 at 12:50pm
Print Post  
Hi, The build output clearly shows the DallasTemperature lib in JAN\Documents\libraries\DallasTemperature?

Did you click "Tools>Visual Micro>Reload Toolchain" after removing the library (or restart the ide)?

Thanks
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Compilation Error. I don't understand why I get it
Reply #10 - Dec 16th, 2013 at 4:22pm
Print Post  
Tim@Visual Micro wrote on Dec 16th, 2013 at 12:50pm:
Hi, The build output clearly shows the DallasTemperature lib in JAN\Documents\libraries\DallasTemperature?

Did you click "Tools>Visual Micro>Reload Toolchain" after removing the library (or restart the ide)?

Thanks


Tried again today. First checked that the DallasTemperature folder is not left. Started the IDE cleaned the solution and built my project. In the out was this part
SketchLibFolders
s\libraries\DallasTemperature\utility
Is this what you mean ? If so I don't understand because in explorer in path
C:\Users\JAN\Documents\Arduino\libraries
I clearly see DallasTemperature not there. But after doing a file search for DallasTemperature I see the folder (that I deleted) being there Shocked. Now I'm confused
« Last Edit: Dec 16th, 2013 at 4:30pm by Jan Friberg »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation Error. I don't understand why I get it
Reply #11 - Dec 16th, 2013 at 4:30pm
Print Post  
Thanks for the info.

When Visual Micro starts it reads all the lib folders and builds a list of what is available. It does not retain the list of libraries between sessions so this is very confusing to see C:\Users\JAN\Documents\libraries\DallasTemperature in the 
build output.

Can you please create a new sketch and include the OneWire using the Project>Add/Import Sketch Library menu.

Then build and see what happens. Please also confirm that "Tools>Options>Visual Micro>Compiler>Allow parent libs=False"

If the build fails please search your machine for DallasTemperature.cpp. It will be interesting to see where this is located. Thanks
  
Back to top
IP Logged
 
Jan Friberg
Junior Member
**
Offline


Posts: 72
Joined: Dec 13th, 2013
Re: Compilation Error. I don't understand why I get it
Reply #12 - Dec 16th, 2013 at 5:43pm
Print Post  
Tim@Visual Micro wrote on Dec 16th, 2013 at 4:30pm:
Thanks for the info.

When Visual Micro starts it reads all the lib folders and builds a list of what is available. It does not retain the list of libraries between sessions so this is very confusing to see C:\Users\JAN\Documents\libraries\DallasTemperature in the 
build output.

Can you please create a new sketch and include the OneWire using the Project>Add/Import Sketch Library menu.

Then build and see what happens. Please also confirm that "Tools>Options>Visual Micro>Compiler>Allow parent libs=False"

If the build fails please search your machine for DallasTemperature.cpp. It will be interesting to see where this is located. Thanks


I discovered that I had two libraries folders one in
C:\Users\JAN\Documents\libraries\
and one in
C:\Users\JAN\Documents\libraries\arduino
and it seems I removed onewire.h in the latter. After removing the latter library and onewire.h in the first
I now could compile both my old and suggested new project.
I find no option for parent library under
Tools>Options>Visual Micro>Compiler>
Now DallasTemperature.cpp is only in 
C:\Users\JAN\Documents\libraries\DallasTemperature

But I still don't see why removing OneWire.h in DallasTemperature could solve this.

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compilation Error. I don't understand why I get it
Reply #13 - Dec 16th, 2013 at 6:57pm
Print Post  
Great. If you have not altered the default parent libs setting then ignore my message about that.

It sounds like your sketchbook folder is set to C:\Users\JAN\Documents which is why it found the Dallas lib there.

Quote:
But I still don't see why removing OneWire.h in DallasTemperature could solve this.


Good question. You will like the answer as much as I do!

Arduino is good but has a few weaknesses. Notice that when the library file names #includes are added to a sketch they do not include subfolder names and you have no place in any project properties to specify lib locations. This is different to all other development systems. 

Also notice that some libraries contain multiple #includes such as the DallasTemp lib that you have downloaded. This means that the #include will not always match the name of a real lib folder.

So how are the libs discovered during compilation by the Arduino Ide? 

A really crude system searches through the  known library locations looking for each #include (sketchbook/libraries, ide/libraries and ide/hardware/platforms/libraries)

Visual Micro is looking in normal alphabetical order where uppercase and lowercase are treated the same D and d. I think this is the problem and that Arduino is using a different search order.

Hopefully you can see from this that no matter what order an ide searches at some point there is going to be a problem if another library contains files of the same name. In this case it didn't affect the Arduino ide but had the oneWire existed in another lib (with a different alphabetical name) it could well have effected the Arduino Ide but not Visual Micro. So file names are important to Arduino libs and any duplicates can cause the wrong library to be compiled.

I think the author of the DallasTemp lib discovered this problem which is why that library appears to use a file called NewOneWire.h instead of OneWire.h. I also think the author inadvertently included the unused OneWire.h in the zip you used to install the library.

This is my take on things and if we find Arduino has a better way to work we will change our code. The library system in Arduino has been through major design changes this year and reading their developer channel it appears that it will shortly change again. 

We keep monitoring and I think that, after this next round of lib change, the development of this area of the Arduino Api  will stabilize allowing us to concentrate on polish rather than structural changes.

In any event I don't expect the library design changes to remove the inherent Arduino issue caused by duplicate library source file names.

I hope this makes sense, sorry for the info dump
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint