Offline
Newbie
Karma: 0
Posts: 9
|
 |
« on: February 07, 2012, 12:36:38 pm » |
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)
Offline
Brattain Member
Karma: 269
Posts: 25381
Solder is electric glue
|
 |
« Reply #1 on: February 07, 2012, 12:39:12 pm » |
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
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #2 on: February 08, 2012, 01:06:38 pm » |
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
Edison Member
Karma: 30
Posts: 1165
|
 |
« Reply #3 on: February 08, 2012, 01:16:19 pm » |
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
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #4 on: February 08, 2012, 07:30:24 pm » |
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
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #5 on: February 08, 2012, 07:47:46 pm » |
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
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #6 on: February 09, 2012, 01:26:18 am » |
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 (;  { loop(); if (serialEventRun) serialEventRun(); }
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Online
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #7 on: February 09, 2012, 01:47:02 am » |
the code block there is for (;  { loop(); if (serialEventRun) serialEventRun(); } Time to learn about code blocks. Edit your post, select the code and hit the "#" button.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Online
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #8 on: February 09, 2012, 01:48:55 am » |
All these experiments gave the same undefined loop error in min.cpp min.cpp? Copy and paste the actual message.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Online
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #9 on: February 09, 2012, 01:51:47 am » |
I have attempted to load the example library TEST
What example library TEST? Where did you find that?
|
|
|
|
|
Logged
|
|
|
|
|
Gosport, UK
Offline
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #10 on: February 09, 2012, 02:28:27 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #11 on: February 09, 2012, 12:34:52 pm » |
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 (;  { 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
Edison Member
Karma: 11
Posts: 1047
|
 |
« Reply #12 on: February 09, 2012, 12:36:40 pm » |
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
Edison Member
Karma: 11
Posts: 1047
|
 |
« Reply #13 on: February 09, 2012, 12:42:15 pm » |
hrumph why don't you use the code in the example #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
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #14 on: February 09, 2012, 02:36:34 pm » |
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
|
|
|
|
|
|