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
Hot Topic (More than 8 Replies) Problems compiling custom library in debug mode (Read 15711 times)
Woodcam
Junior Member
**
Offline


Posts: 15
Joined: Jan 21st, 2013
Problems compiling custom library in debug mode
Jan 31st, 2013 at 4:09pm
Print Post  
Added <file>.cpp and <file>.h to project to implement MVC architecture which in turn uses the RTClib and Wire libraries. The problem is that the Arduino library references do not resove correctly when compiling with the debug option. The same problem occurs when the files are either in the immediate local directory with the controller *.ino file or when they are moved to their own respective library location in the Arduino library hierarchy.  Cry

The error:

Compiling debug version of 'TimeTest2' for 'Arduino Uno'
ChickCoopCtl.cpp.o : : In function `ChickCoopCtl::getTime(char*, char*)':
ChickCoopCtl.cpp : now()'
ChickCoopCtl.cpp : now()'
ChickCoopCtl.cpp.o : : In function `ChickCoopCtl':
ChickCoopCtl.cpp : undefined reference to `Wire'
ChickCoopCtl.cpp : undefined reference to `Wire'
ChickCoopCtl.cpp : begin()'
ChickCoopCtl.cpp : begin()'
avr-objcopy* : : : No such file
avr-objcopy* : : : No such file

The first compiler pass succeeds but the link level fails. This same code compiles and loads successfully if the debug option is set to release. I have changed the references to wire to the underlying TwoWire class and instansiated RTC_DS1307 rather than use the static class reference to no avail - both versions work in release but above errors in debug. Cry
« Last Edit: Jan 31st, 2013 at 6:01pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems compiling custom library in debug mode
Reply #1 - Jan 31st, 2013 at 6:04pm
Print Post  
Hi,

I have split this out to a new thread because it would be unfair for other people who have switch on email notifications to receive emails about your issue (which is also different to the original thread).

It is much better to make new threads with your own specific problems. It makes it easier to discuss the issue without having to read other unrelated posts and allows you to specify a more accurate title for the post.

Because this post only applies to debug compile I have also moved this thread from "Project Guidance" to the debugger beta section.

Please zip and email your sketch folder and the library so that I can try it. Also let me know (overview) of what breakpoints you have set in which source files.

Thanks

  
Back to top
WWW  
IP Logged
 
Woodcam
Junior Member
**
Offline


Posts: 15
Joined: Jan 21st, 2013
Re: Problems compiling custom library in debug mode
Reply #2 - Feb 1st, 2013 at 4:12pm
Print Post  
Problem solved Smiley

The linker looks at the base Arduino <target>.ino file to resolve core library links. All user library code includes that reference core libraries must also be added to the base <target>.ino file. 

In addition, in the <target>.ino file, the <stdint.h> library must be included before the Wire and RTClib includes in order to resolve the unint<width>_t type references.

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems compiling custom library in debug mode
Reply #3 - Feb 1st, 2013 at 5:36pm
Print Post  
Thanks for the update.

So am I right in saying that in your .ino program source you are including elements of the arduino core manually?
  
Back to top
WWW  
IP Logged
 
Woodcam
Junior Member
**
Offline


Posts: 15
Joined: Jan 21st, 2013
Re: Problems compiling custom library in debug mode
Reply #4 - Feb 1st, 2013 at 6:40pm
Print Post  
The core libraries are added by using the VS Add Arduino Library menu dropdown, the stdint.h reference must be added manually.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems compiling custom library in debug mode
Reply #5 - Feb 1st, 2013 at 9:28pm
Print Post  
Do you think the debugger should include these files automatically, I'm not sure if that would be possible because it might break the flexibility of allowing people to override the types??

Maybe it could do something automatically and provide a config setting to disable the feature. 

I'm not sure how to proceed with this one but it's good you found the solution and great that you published it.
  
Back to top
WWW  
IP Logged
 
Woodcam
Junior Member
**
Offline


Posts: 15
Joined: Jan 21st, 2013
Re: Problems compiling custom library in debug mode
Reply #6 - Feb 1st, 2013 at 10:40pm
Print Post  
I am not an Arduino expert Cool, I found this solution from another post on the web, although my initial suspicion that it was a linker problem proved correct. The Arduino linker uses the library includes in the <target>.ino to resolve link references and does not check user library files for cross references to other or core libraries. 

Any changes would have to be made cognizant of the Arduino environment.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems compiling custom library in debug mode
Reply #7 - Feb 2nd, 2013 at 3:07am
Print Post  
You probably know more about it than me. The debugger is simple and just includes the arduino.h which I would have expected to provide coverage for the entire arduino core.

I'm having a problem understanding why this failed with the debugger enabled. Do you have tracepoints in cpp files or are you just using .ino files.

The debugger isn't supposed to be doing anything with libraries at the moment so should be unaffected by any libs.

To test the debug compile problem, can I simply include the libraries you mention in n empty arduino sketch and try to debug? Will I hit the problem you hit?
  
Back to top
WWW  
IP Logged
 
Woodcam
Junior Member
**
Offline


Posts: 15
Joined: Jan 21st, 2013
Re: Problems compiling custom library in debug mode
Reply #8 - Feb 3rd, 2013 at 3:55pm
Print Post  
There is a wiki site on Google that documents Arduino and the compile link process - http://code.google.com/p/arduino/. 

There is a compilation section which also points out that references to library files not referenced in the main <target>.ino file must be included in the <target>.ino. Once this accepted and proscribed procedure is followed there is no error between the release and debug compilations. In other words this procedure must be followed to adhere to the Arduino environment.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems compiling custom library in debug mode
Reply #9 - Feb 3rd, 2013 at 5:27pm
Print Post  
Hi,

Yes I know the compile process well however I am obviously not being clear with my question. 

You say the the project compiled fine in release mode but not in debug mode?

Sorry I don't understand the difference? 

The debugger doesn't reference any libraries. 

What am I missing? Sorry to be a pain.
  
Back to top
WWW  
IP Logged
 
Woodcam
Junior Member
**
Offline


Posts: 15
Joined: Jan 21st, 2013
Re: Problems compiling custom library in debug mode
Reply #10 - Feb 3rd, 2013 at 7:33pm
Print Post  
The original post refers to the fact that the linker failed because I did not include the referenced libraries in the <target>.ino file. The subsequent posts detail the solution, referenced libraries must be included in the <target>.ino file even when not referenced directly in the <target>.ino file. Once the solution procedures are followed there are no errors either in release or debug compilations. Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems compiling custom library in debug mode
Reply #11 - Feb 3rd, 2013 at 8:04pm
Print Post  
Hi,

Yes I understand that but your original post said that it linked fine in "Release" mode but not in "Debug". 

I also understand that with some arduino libs you need to add in certain parts of the arduino core to the sketch manually.

So adding <stdint.h> early in the sketch code solves the issue but from my perspective a debug compile should work the same as a release compile.

From what you say, am I correct in thinking that the unint<width>_t reference in the vm debugger code would have caused the difference between the two compilations?

If so, then I am wondering if vm should automatically force <stdint.h> into the debug compile.

Thanks
  
Back to top
WWW  
IP Logged
 
Woodcam
Junior Member
**
Offline


Posts: 15
Joined: Jan 21st, 2013
Re: Problems compiling custom library in debug mode
Reply #12 - Feb 3rd, 2013 at 9:20pm
Print Post  
The  the unint<width>_t reference is a compile error, not a linker error. The Arduino compiler does not load stdint.h automatically while VS does.

Referencing stdint.h automatically pre-compile probably will not be affect other compile outcomes.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems compiling custom library in debug mode
Reply #13 - Feb 3rd, 2013 at 11:34pm
Print Post  
Hi, Yes I forgot to say that I can add it to the main .ino during debug compile, vm already adds other stuff when required. Then it will be picked up in the same way as if the user had added it to the sketch.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint