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


Posts: 6
Joined: Jun 4th, 2018
RTClib.h help required
Aug 21st, 2018 at 7:08pm
Print Post  
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
Select All
#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
Select All
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
Select All
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
Joined: Jun 4th, 2018
Re: RTClib.h help required
Reply #1 - Aug 24th, 2018 at 1:55pm
Print Post  
I managed to fix it by installing the Zip then editing 

Code
Select All
#include "RTClib.h" 


to
Code
Select All
#include <RTClib.h> 



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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: RTClib.h help required
Reply #2 - Aug 25th, 2018 at 12:10pm
Print Post  
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
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: RTClib.h help required
Reply #3 - Aug 30th, 2018 at 12:50am
Print Post  
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
« Last Edit: Aug 30th, 2018 at 3:41am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint