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) undefined reference to vtable for HardwareSerial (Read 3862 times)
MacGuyver
Newbies
*
Offline


Posts: 9
Joined: May 7th, 2021
undefined reference to vtable for HardwareSerial
May 12th, 2021 at 1:33pm
Print Post  
Updated to the very latest 1.2021.0427.
I got the following error on 1.2021.0420 as well.

So now I'm getting the following error during Linking:

Code
Select All
Error linking for board P1AM-100
Build failed for project 'IO_Controller'
core.a(Uart.cpp.o)*: In function HardwareSerial::HardwareSerial()
HardwareSerial.h:67: undefined reference to vtable for HardwareSerial

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



Attaching the build output.

I used to get this error when I had Core optimization enabled, it went away when I disabled it, and now it's back again.
« Last Edit: May 12th, 2021 at 1:34pm by MacGuyver »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2142
Joined: Feb 13th, 2019
Re: undefined reference to vtable for HardwareSerial
Reply #1 - May 12th, 2021 at 2:48pm
Print Post  
When you change the optimization, with Shared Cached Core files, Solution > Clean needs to be run to force the core to recompile.

Does this improve if you run Build > Clean Solution, and Rebuild?
  
Back to top
 
IP Logged
 
MacGuyver
Newbies
*
Offline


Posts: 9
Joined: May 7th, 2021
Re: undefined reference to vtable for HardwareSerial
Reply #2 - May 12th, 2021 at 8:43pm
Print Post  
It doesn't seem to make any difference unfortunately.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to vtable for HardwareSerial
Reply #3 - May 12th, 2021 at 11:23pm
Print Post  
Please repost the output. The optimization for the project code was certainly disabled in the verbose output you posted. 

You can see the -O0 switch in the output when optimization is disabled.
  
Back to top
WWW  
IP Logged
 
MacGuyver
Newbies
*
Offline


Posts: 9
Joined: May 7th, 2021
Re: undefined reference to vtable for HardwareSerial
Reply #4 - May 13th, 2021 at 11:13am
Print Post  
Ah, I seem to have found the issue.

I was relying on the optimization setting from the drop-town toolbar, which apparently is NOT the same as setting the "Disable Optimization [Core/Libraries/Project]" under the properties tab.

When I change the optimization from the tool bar dropdown it doesn't change anything.  Changing from the properties panels does work.

In addition, why is optimization excluding something that is obviously required?


  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to vtable for HardwareSerial
Reply #5 - May 13th, 2021 at 5:14pm
Print Post  
The F4 properties overrides and is based on the current configuration.

I think the question about optimization has to be directed at the author of the core. This is because some cores have been designed specifically for the level of optimization the author has set in the platform.txt build instructions. That is what Visual Micro uses by default unless you override it. 

Out of interest, what was the reason for switching off optimization?
  
Back to top
WWW  
IP Logged
 
MacGuyver
Newbies
*
Offline


Posts: 9
Joined: May 7th, 2021
Re: undefined reference to vtable for HardwareSerial
Reply #6 - May 13th, 2021 at 9:35pm
Print Post  
I switched off optimization as a test, because it seemed like the only reason a previously working core component would break (hardware serial)
  
Back to top
 
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: undefined reference to vtable for HardwareSerial
Reply #7 - May 24th, 2021 at 10:23pm
Print Post  
I'm having a very similar problem.  The project's .ino file compiles fine with the Arduino IDE, but gives the 

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

ccbs3Ofd.ltrans0.ltrans.o*: In function global constructors keyed to 65535_0_FourWD_PulseTurnRateTest.cpp.o.2415
   (.text.startup+0x5e): undefined reference to MPU6050::MPU6050(unsigned char)

when compiled with VS2019/VM.

Verbose compile outputs attached

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: undefined reference to vtable for HardwareSerial
Reply #8 - May 24th, 2021 at 10:27pm
Print Post  
I haven't made any changes to the optimization settings from the default.  The project is a brand-new project created with 'File -> New -> Arduino Project.

  
Back to top
 
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: undefined reference to vtable for HardwareSerial
Reply #9 - May 24th, 2021 at 10:29pm
Print Post  
Here's the verbose with build properties output

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2142
Joined: Feb 13th, 2019
Re: undefined reference to vtable for HardwareSerial
Reply #10 - May 25th, 2021 at 10:53am
Print Post  
Thanks for the detail, and as discussed on Email the remaining C/CPP/H files need to be added to the Project (Right click project > add > Existing Items > Select all missing files > OK).

Can you confirm, how you created this project, and whether the C/CPP/H files were present when this was created?
  
Back to top
 
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: undefined reference to vtable for HardwareSerial
Reply #11 - May 25th, 2021 at 2:36pm
Print Post  
Simon@Visual Micro wrote on May 25th, 2021 at 10:53am:
Thanks for the detail, and as discussed on Email the remaining C/CPP/H files need to be added to the Project (Right click project > add > Existing Items > Select all missing files > OK).

Can you confirm, how you created this project, and whether the C/CPP/H files were present when this was created?


Thanks for the prompt and complete reply - that did the trick.  After all the years I've put in with VS/VM, you'd think I could remember that one  Tongue

I'm pretty sure the C/CPP/H files were NOT present when the project was first created.

Thanks again!

Frank
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2142
Joined: Feb 13th, 2019
Re: undefined reference to vtable for HardwareSerial
Reply #12 - May 25th, 2021 at 3:21pm
Print Post  
Thanks for confirming the fix, and how the project was created.

Can we also check how you added the files to the project?
1) Just in File Explorer?
2) Via the Folder View of Solution Explorer in Visual Studio?
3) Another route? (e.g. tabs in Arduino IDE if using both IDEs alongside each other)
  
Back to top
 
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: undefined reference to vtable for HardwareSerial
Reply #13 - May 25th, 2021 at 3:31pm
Print Post  
Simon@Visual Micro wrote on May 25th, 2021 at 3:21pm:
Can we also check how you added the files to the project?
1) Just in File Explorer?
2) Via the Folder View of Solution Explorer in Visual Studio?
3) Another route? (e.g. tabs in Arduino IDE if using both IDEs alongside each other)



1) Just in file explorer

BTW, what was the clue or clues that convinced you the problem was the lack of project references, other than 'missing reference'?  Is 'missing reference' the smoking gun?

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to vtable for HardwareSerial
Reply #14 - May 26th, 2021 at 10:45pm
Print Post  
Yes, especially if files are added outside of VS after the project has first been created/opened. 

Tip:

Did you click the little icon above the solution explorer called "Show all files"? 

That should show a red exclaimation mark for any files you have added via windows explorer but have not yet set to be "Include in Project"?

You can right click the files or folders in that view to "Include in Project"

This gives greater control over which files are compiled and also falls in line with how VS works.
« Last Edit: May 26th, 2021 at 10:48pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: undefined reference to vtable for HardwareSerial
Reply #15 - May 31st, 2021 at 1:04am
Print Post  
Tim,

BTW, created another new Arduino project in VS2019 to create a new version of an existing project.  This time I created the project and saved it (which created the folder), then immediately copied all the relevant local files from the old version into the new folder, and added them to the project using the 'Add -> Existing' right-click selection on the project name, then copied in all the code to make the two projects identical except for the name, and it compiled correctly the first time.

Thanks again!

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: undefined reference to vtable for HardwareSerial
Reply #16 - May 31st, 2021 at 2:22am
Print Post  
Great but you can just copy your sources to a new folder (without any .vcxproj files) then click "File>Open>Arduino Project". 

The "Open Arduino Project" allows you to select the .ino file, then Visual Micro creates a project and automatically adds all the sources.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint