Pages: [1]   Go Down
Author Topic: undefined reference to 'loop' building TESTexample library  (Read 1010 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a new UNO R3 board and am on a windows 7 machine. I have attempted to load the example library TEST, which produces the error undefined reference to 'loop'. Even though I believe the problem is in the linkage of the libraries, I really need explicit steps in how to correct this or another work around.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33961
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have attempted to load the example library TEST, which produces the error undefined reference to 'loop'.
So post the code and the error message.

Moderator edit: topic moved, thanks Mike.
« Last Edit: February 07, 2012, 01:00:14 pm by AWOL » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only reference to "loop" is in doing_something.pde
provided with the TEST library
i.e.
void loop()
{
  myTest.doSomething();
  delay(500);
}

The error produced is  .../arduino\cores\ardino/main.cpp:14:
undefined reference to loop
Interestingly if the all to loop is commented out in doing_something.pde the same error is produced.
I'm totally confused .

Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 69
Posts: 2166
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Post the actual sketch file or code. That error is commonly linked to incorrect function names, can your sketch see the setup function and is it in the same file as the loop function.
Ensure the 'loop' word is all lowercase.
Also if you are using the latest arduino ( 1.0 ) you should rename your .pde file to .ino
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Things are really bizarre.
First as requested here's the sketch as it appears from the Arduino web site.
include <Test.h>

// Doing Something
// by John Doe <http://www.yourwebsite.com>

// Demostrates how to do something with the Test library

// Created 1 April 2006

Test myTest = Test(2);

void setup()
{
}

void loop()
{
  myTest.doSomething();
  delay(500);
}
second I tried other provided  libraries and got the same error
third   I made a bare library with only an .h file and a .cpp file.
the only entry is the include directive. No matter what I do by way of adding code I get the same same error.
I must conclude that I think there is something wrong with the core library, at least when it comes to importing libraries.
I do not know how to re-implement the embedded software and would  value some help.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49071
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have attempted to load the example library TEST, which produces the error undefined reference to 'loop'. Even though I believe the problem is in the linkage of the libraries, I really need explicit steps in how to correct this or another work around.
Where did you get this library? The include statement is wrong in the code you posted. The # is missing.

If you are really interested in help. you'll copy and paste code properly, and provide a link so other people can look at the actual library.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got the library from the site http://www.arduino.cc/en/Main/Libraries by clicking on the Test library link and adding the unzipped down load into a sub folder of the library folder.
I also tried using the Time library from the Arduino library web site. I further tried a library from the provided libraries.
All these experiments gave the same undefined loop error in min.cpp  line 14 which is loop();
the code block there is
for (;smiley-wink {
      loop();
      if (serialEventRun) serialEventRun();
   }
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the code block there is
for (;smiley-wink {
      loop();
      if (serialEventRun) serialEventRun();
   }

Time to learn about code blocks. Edit your post, select the code and hit the "#" button.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
All these experiments gave the same undefined loop error in min.cpp 

min.cpp?

Copy and paste the actual message.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have attempted to load the example library TEST

What example library TEST? Where did you find that?
Logged


Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's here: http://arduino.cc/en/uploads/Main/Test.zip
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The reference to line 14 is in main.cpp.
The code for this is in ../hardware/arduino/cores/arduino
it is short therefore I reproduce it here.:
#include <Arduino.h>

int main(void)
{
   init();

#if defined(USBCON)
   USB.attach();
#endif
   
   setup();
   
   for (;smiley-wink {
      loop();
      if (serialEventRun) serialEventRun();
   }
       
   return 0;
}
I note that it contains the include directive
#include <Arduino.h>
which contains the definition of loop i.e
void loop(void);
So I must assume that somehow the complied and cached library is different from the code as if I make a simple sketch , that contain a loop, not relying on any of the imported libraries, it compiles and runs correctly. When any library is imported the error is displayed. It is not the library but something to do with how the library is linked. At this point I am lost.
Logged

Leighton Buzzard, UK
Offline Offline
Edison Member
*
Karma: 21
Posts: 1339
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

put your code inside code tags

[ code]
your code
[ /code]
then we see code not smilies!
Logged

there are only 10 types of people
them that understands binary
and them that doesn't

Leighton Buzzard, UK
Offline Offline
Edison Member
*
Karma: 21
Posts: 1339
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hrumph
why don't you use the code in the example
Code:
#include <Test.h>

// Doing Something
// by John Doe <http://www.yourwebsite.com>

// Demostrates how to do something with the Test library

// Created 1 April 2006

Test myTest = Test(2);

void setup()
{
}

void loop()
{
  myTest.doSomething();
  delay(500);
}

I changed the includes to run under IDE 1.0 and it works
Logged

there are only 10 types of people
them that understands binary
and them that doesn't

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Problem solved.
I had been using an example which had only the include directive but no code.  As soon as I put in the actual example code it worked. To further prove the point I used the more complex Time library. For this I just put in a simplified example which just printed out parts of the time. I really must thank you for your help, for though I feel that the error led me in a red herring path it was indeed a learning experience.
Logged

Pages: [1]   Go Up
Jump to: