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 Playing Whack-A-Mole with the compiler (intellisense) (Read 2240 times)
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Playing Whack-A-Mole with the compiler (intellisense)
May 6th, 2018 at 4:53am
Print Post  
For the past three days I have been chasing a bug the likes of which I have never seen before. The essence of the bug is that the compiler changes its mind while I am looking at the code it objects to. I know that sounds very vague, but here is what happens:

1) Compile and get an "Undefined reference to Commands L9110_Motor" on four consecutive lines. 
2) I look at the definition of the L9110_Motor class which descends from the virtual class GenericMotorDriver. The compiler has flagged this class as non-existent. 
3) I look at the offending GenericMotorDriver class and see that there are now a large bunch of errors in the Error List (see the Compiler Output.txt file in the attached ZIP)
4) I look at the  GenericMotorDriver.cpp  and now the errors disappear (See picture 2)
5) I switch back to the GenericMotorDriver.h file and it is now fine with no errors showing (see picture 3)
6) I go back to the declaration of the L9110_Motor class and it looks fine (picture 4)

What the heck is happening here? I have spent three days chasing my tail on this one. Any ideas?
« Last Edit: May 7th, 2018 at 12:26am by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Playing Whack-A-Mole with the compiler
Reply #1 - May 6th, 2018 at 12:34pm
Print Post  
There is a difference between visual studio c++ intellisense which is confusing things bit for you. 

I suggest you switch the combobox at the top of the errors list from "Build+Intellisense" to "Build Only"

Then your report will be as shown below.

A linker error can be a few things. One possibly unrelated item is that if your own code created a source code with the same name as a library that will cause a linker error. In fact the download link in the latest release notes gives you an update that allows your project code to replace any library or core source code.

The error says there is an undefined reference to Commands.



Code (C++)
Select All
Linking it all together ...
"D:\Arduino\hardware\tools\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p
.....

ccAV1zsf.ltrans0.ltrans.o*: In function initializeMotors
Commands.cpp:1230: undefined reference to Commands  L9110_Motor  L9110_Motor()
Commands.cpp:1231: undefined reference to Commands  L9110_Motor  L9110_Motor()
Commands.cpp:1232: undefined reference to Commands  L9110_Motor  begin(char*, int, int)
Commands.cpp:1233: undefined reference to Commands  L9110_Motor  begin(char*, int, int)

collect2.exe*: error: ld returned 1 exit status

Error linking for board Arduino Nano w/ ATmega328P
 

  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: Playing Whack-A-Mole with the compiler (intellisense)
Reply #2 - May 18th, 2018 at 5:29am
Print Post  
Tim,

I have cleaned up much of my code but ran into a nasty problem when two modules use the same interrupt. The real problem is a bit more complex.

I use dozens of define statements to determine what options to compile into this specific robot. For example, does it use an L298N or L9110 H-bridge with the motors? I want one, but not both of the libraries to be included in the compiled code. That is pretty straight forward, but what I am seeing is that all library classes that I even reference (add reference) wind up passing through the linker and that is where the conflicts emerge. 

I just spent two days battling with this issue, wondering why I was getting a warning that __vector_11 was somehow clashing with servo. The Servo code is not being compiled into my robot, but it was a referenced library because using the servo is one of the options I can choose.

Can you recommend a strategy to deal with this? 
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Playing Whack-A-Mole with the compiler (intellisense)
Reply #3 - May 18th, 2018 at 12:29pm
Print Post  
Thanks that is really useful.

Please apply the update from the current work in progress link which has a download for 1805.18.0

The "vMicro>Compiler>Deep Search for Libraries" was ALSO still using the older arduino regex to find libs in .ino files. That would cause conditional #includes in .ino code to always be linked regardless of condition.

Deep search uses GCC-E to intelligently discover includes which is what you need.

minor: Deep search default to ON but check you have not switched it off.

Sorry for the confusion and thanks for the post

« Last Edit: May 18th, 2018 at 12:32pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint