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) Force user library instead of system library (Read 1830 times)
Jyce
Newbies
*
Offline


Posts: 9
Joined: Jan 24th, 2017
Force user library instead of system library
Dec 30th, 2022 at 10:26am
Print Post  
Hi all,
I case I have the same arduino library in :
- C:\Program Files (x86)\Arduino\hardware\XXX\avr\libraries\MyLibrary\
- C:\Users\User\Documents\Arduino\libraries\MyLibrary\

How to tell Visual Micro to use the user one ?
Right now, it selects the system one Sad

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force user library instead of system library
Reply #1 - Dec 30th, 2022 at 2:54pm
Print Post  
There are a number of ways. The default that you see is following the arduino rules. You can change things but it's impossible to help without the information requsted yellow above.
  
Back to top
WWW  
IP Logged
 
Jyce
Newbies
*
Offline


Posts: 9
Joined: Jan 24th, 2017
Re: Force user library instead of system library
Reply #2 - Dec 30th, 2022 at 3:30pm
Print Post  
Oh sorry.
Here are the informations.

The library in question is "LittleFS".
I installed it in the C:\Users\User\Documents\Arduino\libraries\ folder to apply some modifications. But it already exists in C:\Program Files (x86)\Arduino\hardware\XXX\avr\libraries\
  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force user library instead of system library
Reply #3 - Dec 30th, 2022 at 5:02pm
Print Post  
Thanks, the Teensy boards represent themselves as avr even though they are not. That is by design of the manufacturer because they are usually compatible with all avr libs.

Look at the library.properties of your downloaded library. It's a text file that contains an architecures= property.

I expect the library in the platform\avr folder has architectures=avr and the one you downloaded probably has architectures=* or maybe it had architectures=esp8266, esp32

In any event, if a library has architectures=avr and you are using a board that represents itself as avr then that library will win.

You can change the downloaded library to be architectures=esp8266, esp32, avr or architectures=avr. Then click rescan or restart the ide.

The one in the platform is winning because it states clearly it is for avr. architectures=* has lowest priority and means "any".

An alternative workaround is to use a shared library project in visual micro which is then added as a Refrernce to the Arduino project. Shared library projects allow you to force an exact version/location of a library and works outside of all the normal arduino rules.

Does this make sense?




  
Back to top
WWW  
IP Logged
 
Jyce
Newbies
*
Offline


Posts: 9
Joined: Jan 24th, 2017
Re: Force user library instead of system library
Reply #4 - Dec 31st, 2022 at 9:32am
Print Post  
Thanks for your explanations.
The two libraries have "architectures=*" in their library.properties files.
So, I changed the one on my user folder with "architectures=avr"
I reloaded the toolchain & libraries scan but it continues to use the platform one :/
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force user library instead of system library
Reply #5 - Dec 31st, 2022 at 3:21pm
Print Post  
If they were both =* then the sketchbook/libraries one should win. 

Please provide the information shown in yellow above so that we can see your config. Specifically, the sketch book location which is used to find user libs.
« Last Edit: Dec 31st, 2022 at 7:40pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Jyce
Newbies
*
Offline


Posts: 9
Joined: Jan 24th, 2017
Re: Force user library instead of system library
Reply #6 - Dec 31st, 2022 at 5:28pm
Print Post  
Here the library.properties files :

C:\Users\User\Documents\Arduino\libraries\
name=LittleFS
version=1.0.0-custom
author=Paul Stoffregen/Custom
maintainer=Paul Stoffregen/Custom
sentence=LittleFS for Teensy
paragraph=Access flash memory chips as a filesystem, build in top of ARM's littlefs.
category=Data Storage
url=https://github.com/PaulStoffregen/LittleFS
architectures=avr



C:\Program Files (x86)\Arduino\hardware\XXX\avr\libraries\
name=LittleFS
version=1.0.0
author=Paul Stoffregen
maintainer=Paul Stoffregen
sentence=LittleFS for Teensy
paragraph=Access flash memory chips as a filesystem, build in top of ARM's littlefs.
category=Data Storage
url=https://github.com/PaulStoffregen/LittleFS
architectures=*


In attachment the build log.


I also tried to change the architectures=* of the platform library by replacing the "*" by "noexist".
Does not change the result :/
  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force user library instead of system library
Reply #7 - Dec 31st, 2022 at 10:18pm
Print Post  
Question: Is the library name in the sketchbook/libraries excatly "LittleFS" or do you have some suffix text on the folder name?
  
Back to top
WWW  
IP Logged
 
Jyce
Newbies
*
Offline


Posts: 9
Joined: Jan 24th, 2017
Re: Force user library instead of system library
Reply #8 - Jan 1st, 2023 at 12:13am
Print Post  
No. The name of the folder is "LittleFS-master" (I download it from github)
  
Back to top
 
IP Logged
 
Jyce
Newbies
*
Offline


Posts: 9
Joined: Jan 24th, 2017
Re: Force user library instead of system library
Reply #9 - Jan 1st, 2023 at 9:53am
Print Post  
Happy new year and thanks for your support Smiley
I just renamed the user library name folder to have the same name as the platform's one ("LittleFS") and it works.
So it seems the library's name folder is important.
See buildlog in attachment.
  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force user library instead of system library
Reply #10 - Jan 1st, 2023 at 6:38pm
Print Post  
Great. yes it is better to put version numbers in parent folder. For example

Libraries\LittleFS\1.0.1\LittleFS

or

Libraries\LittleFS-1.0.1\LittleFS

This because for Arduino we don't specify library paths, they have to be "guessed" at runtime. If two libraries contain "xyz.h" then how do we work out which to use? There is a set of rules that Arduino uses such as:-

Is there a library folder name that matches the .h? If yes then use that one.

Is there a library folder name that matches the .h but also ends with -master? If yes then a github zip was used to install the library. use that one.

If we can't find any #included header that matches a lib folder name then look for any library that contains the .h name. Not very accurate.

In this case you had an exact library folder name that matched a .h. It was in the platform/libraries folder so it was used. 

The library that you installed into sketchbook libraries would have been considered an entirely different library. It would have won only if the LittleFS in platform/libraries had a different name too. Then the LittleFS.h would have been used from the one in sketchbook/libaries.

The architectures= would only apply after two libs of same name are found.

Hopefully this helps.



« Last Edit: Jan 1st, 2023 at 6:41pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Jyce
Newbies
*
Offline


Posts: 9
Joined: Jan 24th, 2017
Re: Force user library instead of system library
Reply #11 - Jan 1st, 2023 at 7:50pm
Print Post  
Thanks for these explanations.
Wouldn't it have been more efficient for the arduino environment to look at the library.properties file to define the name of the library and possibly prioritize according to the architecture, the version and the existence in the user's folder?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force user library instead of system library
Reply #12 - Jan 1st, 2023 at 8:04pm
Print Post  
It is an idea you could mention to them on their github site. It does make sense but suspect it might make support more difficult.

The architectures= alongside single user installed libs location is probably up for consideration already Smiley
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint