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 trouble linking between two projects in a single solution (Read 3717 times)
arclight
Newbies
*
Offline


Posts: 4
Joined: Dec 21st, 2012
trouble linking between two projects in a single solution
Dec 22nd, 2012 at 11:41am
Print Post  
I'm trying to develop some code using projects to link all the assorted bits together, rather than file libraries. I have a project "blink" that contains led.h & led.cpp; these define an led object. Here's the blink.ino, it works:
Code
Select All
#include "led.h"
LEDS::led l(13);
void setup()
{
	l.setDelay(100);
}

void loop()
{
	l.blink();
} 



When I create a second project, "blinkTest", that references the blink project, intellisense seems to work OK, I can call the namespace/class info from the led.h/.cpp, but it won't compile. Here's the code from blinkTest.ino:
Code
Select All
#include <led.h>

LEDS::led ll(13);

void setup()
{
	ll.setDelay(500);

}

void loop()
{

  ll.blink();

} 



...and here is the error message:
Quote:
SketchLibFolders
vr\lib\gcc\avr\4.3.2\include\;
Summary: Header=1 Prototypes=3 Imports=1
+ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -DVISUALMICRO_COMPILER_VER=1 uino" standard" " -o .o"
blinkTest.ino : No such file or directory
blinkTest.ino : 'LEDS' has not been declared
blinkTest.ino : expected constructor, destructor, or type conversion before 'll'
blinkTest.ino : : In function 'void setup()':
blinkTest.ino : 'll' was not declared in this scope
blinkTest.ino : : In function 'void loop()':
blinkTest.ino : 'll' was not declared in this scope
Error compiling
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12167
Location: United Kingdom
Joined: Apr 10th, 2010
Re: trouble linking between two projects in a single solution
Reply #1 - Dec 22nd, 2012 at 8:49pm
Print Post  
Hi,

The vs plugin/compiler works to the Arduino rules which means that you will always have the same compile in VS as we do in the Arduino IDE.

Arduino rules do not support separate projects. VS is more forgiving which is why the intellisense works.

There are a few ways you can work with this. Creating a library is the best solution. After you create the lib and add it to your sketch then you can click "project>show all arduino files". This will "bring" the library sources into the current sketch project allowing you to easily edit the lib source. 

Keep in mind that an arduino lib folder name must match the name of a .h in the lib folder. If you add more .h files after you have included the library in your sketch then click "project>add library>refresh" then ensure the new .h is added as an #include in the sketch. Arduino does not support fully qualified #includes which is why you need to use the lib system. 

Remember that you can create a "Libraries" folder below the "my documents/arduino sketch folder" which keeps your libraries away from the ones installed with the arduino ide.
« Last Edit: Dec 22nd, 2012 at 8:51pm by Tim@Visual Micro »  
Back to top
IP Logged
 
arclight
Newbies
*
Offline


Posts: 4
Joined: Dec 21st, 2012
Re: trouble linking between two projects in a single solution
Reply #2 - Dec 23rd, 2012 at 12:27am
Print Post  
I got the library approach working; thanks so much!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12167
Location: United Kingdom
Joined: Apr 10th, 2010
Re: trouble linking between two projects in a single solution
Reply #3 - Sep 9th, 2015 at 10:03pm
Print Post  
The latest release of Visual Micro allows the Arduino rules to be broken. Code can be in sub folders, the files linked into the solution will be compiled. There is a new "Compatibility" section in Tools>Options which enables the various new features to be disabled if Strict Arduino compatibility is required.

Arduino library sources can also be copied to a designated folder structure below each project. The library sources are compiled and #included in the exact same way as normal Arduino libraries. This means that libraries can be developed and then published/copied to the master Arduino library list and shared within other projects. A new "Add>New Arduino Library" menu item provides a quick way to create a new library but they can also be created manually.

It appears to also now be possible to share code between multiple projects but this has not been well tested.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint