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) Copied working project to new PC, now getting library compile errors (Read 1498 times)
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Copied working project to new PC, now getting library compile errors
Jul 8th, 2020 at 12:13pm
Print Post  
I have a working project on one Win 10 PC that I want to copy in its entirety to a different Win10 PC. Both PCs are Win10 Boxes with current VS2019CE and current VM.  I copied the entire project folder from C:\Documents\Arduino on the source PC to the same place on the destination PC, and copied all required library folders as well.

When I compile on the new PC, I get a number of errors of this type:

 
Code
Select All
RTClib.cpp.o (symbol from plugin)*: In function DateTime::DateTime(unsigned long)
(.text+0x0)*: multiple definition of DateTime::DateTime(unsigned long)
RTClib.cpp.o (symbol from plugin)*: (.text+0x0): first defined here
ld.exe: Disabling relaxation: it will not work with multiple definitions
 

 

Next I created a brand-new arduino project called 'FourWD_I2C_Test_V2' on the destination PC, copied the source code into it, added the appropriate local files and references, and got the same compile errors.

I have created a Google Drive folder called 'FourWD_I2C_Test_V2 Compile Problem' containing ZIP files of everything I could think of that might be relevant:

- 200708_RTCLibCompileProblem.txt - verbose compile output with project properties
- mega_atmega2560.zip - all the temp files created by the compile process
- libraries.zip - the relevant folders from Arduino\Libraries
- FourWD_I2C_Test_V2.zip - the project folder


https://drive.google.com/drive/folders/1tr1ivvoUgy01sQGTohV_f0XfEd6KNcDw?usp=sha...

If anything else is needed I'll be glad to provide it.

TIA,

Frank

« Last Edit: Jul 8th, 2020 at 12:20pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Copied working project to new PC, now getting library compile errors
Reply #1 - Jul 8th, 2020 at 12:24pm
Print Post  
Sorry we can't support user code errors in this forum. I recommend comparing the verbose output between the two versions so that you can see what has changed or is wrong.

It's possible the issue might be related or similar to your last post where you found a code problem. https://www.visualmicro.com/forums/YaBB.pl?num=1594075834
« Last Edit: Jul 8th, 2020 at 12:25pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Copied working project to new PC, now getting library compile errors
Reply #2 - Jul 8th, 2020 at 4:05pm
Print Post  
Tim,

The reason I posted this issue is because I am concerned there is something going on between VS2019 and VM that is causing this to happen.  It appears that VM may be creating double library .CPP & .CPPD files in C:\Users\Frank\AppData\Local\Temp\VMBuilds\FourWD_I2C_Test_V2 and this is causing the compiler to 'see' the RTClib definitions twice.

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Copied working project to new PC, now getting library compile errors
Reply #3 - Jul 8th, 2020 at 4:35pm
Print Post  
Does it build in arduino ide?
  
Back to top
WWW  
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Copied working project to new PC, now getting library compile errors
Reply #4 - Jul 8th, 2020 at 7:26pm
Print Post  
If you change the #include "RTClib.h" then it picks up the local file, and doesn't need to search for the library, avoiding the conflict.

An alternative is to use the Clone for Solution / Project options when including libraries, giving a copy of the library locally within the project/solution which will be used instead.

Video: Adding Libraries with vMicro
Full Docs: Adding Libraries to your Sketch
  
Back to top
 
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Copied working project to new PC, now getting library compile errors
Reply #5 - Jul 8th, 2020 at 8:05pm
Print Post  
It turns out the problem was caused by a VM setting that didn't get copied across with the project folder, combined with the use of a local copy of a library file.  The project on the source PC shows a checkmark by 'Local files Override Library Files' and the project on the destination PC doesn't have this checkmark - so it apparently doesn't get saved in the project folder.

The result of all this was that the RTCLib files were loaded and compiled TWICE, and this caused the 'multiple definition' error I was seeing.  I'm not exactly sure how this happens, but I'm pretty sure it does.

In both projects, RTCLib.cpp/.h were copied from the library folder to the local project folder and then added to the VS solution references list.  On the source PC a 'right-click ->Go To Document' operation goes to the local copy of RTCLib.cpp/h, but on the destination PC it goes to the Arduino\Libraries\RTCLib version.  However (I'm guessing a little bit  here) because the local copies of RTCLib.cpp/h are included as project references, the compiler thinks of them as completely separate entities and compiles them BOTH, thereby causing the errors I am seeing.

In order to remove the duplicate file load/compiles, it appears I either have to enable the 'Local files Override...' or remove the files from the VS solution references list.  

All the above makes some sense, but it now raises the question - why didn't the same thing happen with all my OTHER local library files - and there are a bunch of them?  

A possible answer for this question is that maybe the other referenced "library files" aren't really library files at all; they are all associated with the I2CDevLib ecosystem, and the documentation directs the user to copy the needed files to the local project directory.  I'm not smart enough to figure that part out Wink

In any case, it appears the entire tempest in the teapot was combination of stupidity on my part (for putting the RTCLib.cpp/.h files in my local project folder in the first place) and not understanding that the VM settings (at least the 'Local Files Override..' one) aren't saved in the VS project settings file

Just another day in the life of a Arduino developer Sad

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Copied working project to new PC, now getting library compile errors
Reply #6 - Jul 8th, 2020 at 8:09pm
Print Post  
Great well done. Make sure you copy the __vm sub folder where some settings are stored.

Simon gave some good info previously. Making a copy/clone of libraries using the "Add Library" menu gives you a more obvious way to redefine libraries. It is not quite the same as adding the code directly to the project but often that causes more confusion than it is worth.
« Last Edit: Jul 8th, 2020 at 8:12pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
FrankP
Full Member
***
Offline


Posts: 240
Joined: Oct 19th, 2011
Re: Copied working project to new PC, now getting library compile errors
Reply #7 - Jul 11th, 2020 at 5:33pm
Print Post  
Simon@Visual Micro wrote on Jul 8th, 2020 at 7:26pm:
If you change the #include "RTClib.h" then it picks up the local file, and doesn't need to search for the library, avoiding the conflict.

An alternative is to use the Clone for Solution / Project options when including libraries, giving a copy of the library locally within the project/solution which will be used instead.

Video: Adding Libraries with vMicro
Full Docs: Adding Libraries to your Sketch



In a further development, it now appears that the '#include <file>' form overrides the 'Local Files Override Library Files' selection, which I don't think it should do.  Currently the 'local files override' selection only works for the '#include "file" form.  Why have an option that only works for one of two common #include treatments?

Tim, can you verify that '#include <file>' will ALWAYS choose the library version over a local file of the same name, regardless of the state of the 'Local Files Override Library Files' selection?  If so, this seems like inappropriate behavior; I would expect this selection to completely override file selection, not just for the '#include "file" form.

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Copied working project to new PC, now getting library compile errors
Reply #8 - Jul 11th, 2020 at 5:52pm
Print Post  
<file> will always use search paths, "file" will use relative paths.

I suggest creating your own shared library project with same name as the one you are trying to override. That was you are in full control and a simpler config.

Also, if you want local code but not bump into a library then change the header name.
« Last Edit: Jul 11th, 2020 at 5:52pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint