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
RTClib.h help required (Read 941 times)
donovan.P
Newbies
*
Offline



Posts: 6
RTClib.h help required
Aug 21st, 2018 at 8:08pm
 
Hello, i have just now tried to run the RTClib.h library
here is the website i found it on.

here is the code i have copied into Visual Micro:


Code:
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;

void setup () {
    Serial.begin(9600);
    Wire.begin();
    RTC.begin();
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
}
void loop () {
    DateTime now = RTC.now();
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    delay(1000);
} 



here is the error im getting:

Code:
Compiling 'test' for 'Arduino Mega ADK'

ccAIeOQc.ltrans1.ltrans.o*: In function main
ccAIeOQc.ltrans1.o*: (.text.startup+0x360): undefined reference to RTC_DS1307::begin()
ccAIeOQc.ltrans1.o*: (.text.startup+0x368): undefined reference to RTC_DS1307::isrunning()

Error linking for board Arduino Mega ADK
ccAIeOQc.ltrans1.o*: (.text.startup+0x388): undefined reference to DateTime::DateTime(char const*, char const*)
Build failed for project 'nexus'
ccAIeOQc.ltrans1.o*: (.text.startup+0x390): undefined reference to RTC_DS1307::adjust(DateTime const&)
ccAIeOQc.ltrans1.o*: (.text.startup+0x394): undefined reference to RTC_DS1307::now()

collect2.exe*: error: ld returned 1 exit status 



Note 1: i have copied the following files from the zip to the project's *.ino directory :

Code:
keywords.txt
RTClib.cpp
RTClib.h
 


Note 2: the script works just fine in the normal Arduino IDE

what am i doing wrong? Huh
Back to top
 
 
IP Logged
 
donovan.P
Newbies
*
Offline



Posts: 6
Re: RTClib.h help required
Reply #1 - Aug 24th, 2018 at 2:55pm
 
I managed to fix it by installing the Zip then editing

Code:
#include "RTClib.h" 


to
Code:
#include <RTClib.h> 



so now it's a internal library apparently, and it can 'see' the references made inside of the arduino lib
Back to top
« Last Edit: Aug 24th, 2018 at 9:11pm by donovan.P »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10529
United Kingdom
Re: RTClib.h help required
Reply #2 - Aug 25th, 2018 at 1:10pm
 
Thanks for the update. The lib builds okay for me as per zip.

However I note that library folder name does not match a header name in the lib folder. The folder is called RTC the library header is RTCLib.h.

In this scenario both arduino and visual micro have to search and guess what exact library is required. It's possible for an RTClib.h to be located in another library or location so resolving the exact folder is not an exact science. This is why it is important for library developers to follow the rule or a header file matching the folder name.

If in a situation where we go hunting for a library Visual Micro should do the same as arduino so I will take a look however it's very random and best avoided.

Maybe you also have added an RTClib.h to your project and arduino is ignoring it but visual micro is not or vica versa? Difficult to know without seeing your project and other installed libs.

If I recall "RTClib.h" means look locally, <RTClib.h> means use include paths?
Back to top
 
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10529
United Kingdom
Re: RTClib.h help required
Reply #3 - Aug 30th, 2018 at 1:50am
 
Oh I missed the fact you had copied the library sources to your local sketch project.

The reason why the <include> worked in the arduino ide must be cause the project folder is automatically added to the compiler include paths.

In visual micro this is currently optional. Switch on "tools>options>compiler>Project Folder -I" and then you will have the same as the arduino ide.

We will change the default in the next release. Arduino did not used to add the include path automatically so must have changed at some point.

There was also a possibility of a linker error (.o object already defined) with local library sources especially with a conflicting shared library project in the solution (might not apply to you).

Update: The latest update (1808.30.4) is required to enable project folder includes. The release contains a bug fix for the tools>option mentioned above and is now the default.

Thanks for the report
Back to top
« Last Edit: Aug 30th, 2018 at 4:41am by Visual Micro »  
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print