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 Linker error - truncated error messages? (Read 7623 times)
happyinmotion
Newbies
*
Offline


Posts: 3
Joined: Mar 29th, 2015
Linker error - truncated error messages?
Apr 6th, 2015 at 5:55am
Print Post  
I'm using Visual Studio and getting meaningless errors from the linker. Double clicking on them takes me to lines in the .ino, but the errors themselves seem truncated to me. 

Is this the case?

Version numbers are:
Visual Studio Community Edition 12.0.3
Visual Micro 1503.18
Arduino 1.6.1
Teensyduino 1.21

This hardware and software configuration can happily compile, link, and upload other projects.

The output text is:
...
Hat_VS_VM_1_6_1.cpp.o:In function `Display::~Display()'
Hat_VS_VM_1_6_1.cpp.o:In function `setup'
Hat_VS_VM_1_6_1.ino:TaskScheduler(TimedTask**, unsigned char)'
Hat_VS_VM_1_6_1.ino:setShouldRun(bool)'
Hat_VS_VM_1_6_1.ino:setShouldRun(bool)'
Hat_VS_VM_1_6_1.ino:setShouldRun(bool)'
Hat_VS_VM_1_6_1.ino:setShouldRun(bool)'
Hat_VS_VM_1_6_1.ino:setShouldRun(bool)'
M_1_6_1\teensy31\Hat_VS_VM_1_6_1.cpp:55: more undefined references to `TimedTask::setShouldRun(bool)' follow
Hat_VS_VM_1_6_1.cpp.o:In function `setup'
Hat_VS_VM_1_6_1.ino:run()'
Hat_VS_VM_1_6_1.cpp.o:In function `loop'
Hat_VS_VM_1_6_1.cpp.o:In function `__static_initialization_and_destruction_0'
Hat_VS_VM_1_6_1.h:BVSensor(unsigned long)'
Hat_VS_VM_1_6_1.h:ClockTick(unsigned long)'
Hat_VS_VM_1_6_1.h:TemperatureSensor(unsigned long)'
Hat_VS_VM_1_6_1.h:StatusLED(unsigned char, StatusLEDMode, unsigned short)'
Hat_VS_VM_1_6_1.h:SwitchModes(unsigned long)'
Hat_VS_VM_1_6_1.h:RotarySwitch(unsigned long)'
Hat_VS_VM_1_6_1.h:TestHarness(unsigned long)'
Hat_VS_VM_1_6_1.h:MotionSensor(unsigned long)'
Hat_VS_VM_1_6_1.h:PatternGenerator(unsigned long)'
Hat_VS_VM_1_6_1.h:PatternGenerator(unsigned long)'
Hat_VS_VM_1_6_1.h:Display(unsigned long)'
collect2.exe*:error: ld returned 1 exit status
Error creating .elf
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Linker error - truncated error messages?
Reply #1 - Apr 6th, 2015 at 6:24am
Print Post  
wild guess is that a duplicate timer library file does not contain the definition for TimedTask or you are missing a define.

Where is TimedTask defined?


  
Back to top
IP Logged
 
happyinmotion
Newbies
*
Offline


Posts: 3
Joined: Mar 29th, 2015
Re: Linker error - truncated error messages?
Reply #2 - Apr 6th, 2015 at 6:52am
Print Post  
That's a worry. TimedTask is defined in a user library called HappyLEDs. This includes the class definitions in a set of files, one per class, to keep things tidy. These are all included in a utility sub-folder in the HappyLEDs folder.

So Hat_VS_VM_1_6_1.h has:
#include <HappyLEDs\HappyLEDs.h>

And HappyLEDs.h includes the files for each class with:
#include "utility/TimedTask.h"
#include "utility/TaskScheduler.h"
#include "utility/SwitchModes.h"
#include "utility/BVSensor.h"
etc...
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Linker error - truncated error messages?
Reply #3 - Apr 6th, 2015 at 5:18pm
Print Post  
Does it build okay with the arduino ide? You will need to remove the libname\ prefix from the #includes
« Last Edit: Apr 6th, 2015 at 5:19pm by Tim@Visual Micro »  
Back to top
IP Logged
 
happyinmotion
Newbies
*
Offline


Posts: 3
Joined: Mar 29th, 2015
Re: Linker error - truncated error messages?
Reply #4 - Apr 7th, 2015 at 6:53am
Print Post  
That's weird...

It wasn't compiling with the Arduino IDE (both 1.0.5 and 1.6.1). I expected that, due to Visual Micro needing the libname prefix. However, removing that results in the error:
In file included from Hat_VS_VM_1_6_1.ino:2:0:
Hat_VS_VM_1_6_1.h:14:23: fatal error: HappyLEDs.h: No such file or directory

In the header file, I've tried:
#include <HappyLEDs\HappyLEDs.h>
#include "HappyLEDs\HappyLEDs.h"
#include <HappyLEDs.h>
#include "HappyLEDs.h"

All give the same error.

I say this is weird, because the HappyLEDs.h file is in the right place (....\workspace\libraries\HappyLEDs), the IDE is looking in the right place, the file has a valid name (matches the directory name and doesn't have prohibited characters), and the content is valid. If I use the Import Library functionality in both the Arduino IDE and Visual Studio, the HappyLEDs library appears in the list of libraries and the code inserted by that functionality is #include <HappyLEDs.h>.

Further fiddling around reveals that the error occurs if the library include is in the main header file (Hat_VS_VM_1_6_1.h) whereas if the #include <HappyLEDs.h> line goes at the start of the Hat_VS_VM_1_6_1.ino file, then there is no error and my code compiles successfully in both the Arduino IDE and Visual Studio/Visual Micro.

I remain somewhat confused by the Arduino build process and the resulting errors. In this case, putting the library includes in the .ino works and putting them in the .h doesn't.
« Last Edit: Apr 7th, 2015 at 6:55am by happyinmotion »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Linker error - truncated error messages?
Reply #5 - Apr 7th, 2015 at 1:59pm
Print Post  
Libs are resolved in order of #include. 

So adding at the top of the code will cause all files from within the lib to be discovered first.

It can be a problem when two libs contain the same header file and when a misc header just so happens to be the name of another library.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint