Visual Studio 2010 external editor

Hi... I'm trying to configure Visual Studio(VS) to create libraries for the arduino. I would really appreciate communicating with some who has gotten VS to work - especially in creating .h/.cpp files that can be compiled.

When I go to compile the file it immediately pukes when trying to load WProgram.h...

So as another test, I just created a simple program below...

I have tried configuring Visual studio in the following ways: 1) Under tools/options/text editor/file extension, I added an entry: pde - Microsoft Visual C++ 2) Under project/properties/configuration properties/v++ properties/include directories: I added: filepath\Arduino\libraries filepath\Arduino\hardware\tools\avr\lib\gcc\avr\4.3.2 filepath\Arduino\hardware\tools\avr\avr\include filepath\Arduino\hardware\arduino\cores\arduino

3) then I create a new VS project called ArduinoVS and create an ArduinoVS.pde file (code below)

When I try to compile in the Arduino editor, I get errors: unreferenced main, loop...

ifdef _MSC_VER

define attribute(x)

define inline

define __cplusplus

define __builtin_va_list int

define asm(x)

include "WProgram.h"

void setup(){

Serial.begin(9600); }

void loop(){ Serial.print("Hello");

delay(1000); }


Can anybody help?

Arduino pde sketches include a hidden copy of a main function. The function looks like this and you would need to add the equivalent yourself to your VS Studio project.

int main(void)
    for (;;)  loop();
    return 0;

An alternative might be to look closer at this project:

Hi... I'm not sure how to implement what you are suggesting... Do you have an example? Something that shows what I do on the Visual Studio side, and then what I do on the Arduino side.

I would rather not go down the road of adding more software if I can avoid it.

In simple terms, I still don't know if I am compiling anything in Visual Studio - or just using it as a text editor...

My primary desire is to code a library (.cpp and .h) files, compile them to find out if there are any syntax errors, and then place them in the hardware directory. Then import the library into Arduino.

So far, I'm not finding answers as to how Visual Studio helps me code libraries? I guess I was assuming that I would import a bunch of libraries in the header or configure Visual Studio correctly to find all of the underlining libraries to allow me to successfully compile.

I provided a detailed list of what I did before, perhaps I missed something...

Let me ask you this: Which PART of ViStudio are you wanting to use? C++, C#, VB, ETC.? I don't quite know if Visual Studio even outputs hex files, or what you could do to make it do so. The hex files are the real stars of the show so to speak with AVR chips and arduino. The pde files are really just compilations of code you have written in plain text format. You can open them yourself in notepad if you wanted.

If I were you, and wanted to code outside of the Arduino IDE, I would either get adapted to AvrStudio4 and use gcc coding (not really that much different than Arduino IDE's coding, but misses the point of the arduino bootloader for simplicity.), or use a more popular open source c compiler that you could find out from the originator of that app as to what you can do to customize it. When it comes to microsoft products, I am sure there is a way to do what you want to do with it but not without a LOT of coding.

OH! I think I see what you are talking about! Are you looking for an IDE with advanced debugging options? Best thing to do in that case is use AVR studio. You can even see a simulation of the pins of your chip running with the program, and would probably take the headers easily from Arduino. It also includes step in, step out, and even step around debugging. Pretty sweet stuff, I just don't feel comfortable with the complexity of pin addressing :/ But if it did support arduino ide style code, I would use it.

Thanks for answering… I’m only using the C++ part of Visual Studio.

My only interest in using it is to code some libraries for the Arduino… Like any other C++ program I would like to compile them to make sure they are syntatically correct… But to do so, it needs to be able to find WProgram.h and any other .h program I include in my library - else Visual Studio is barfing saying it can’t locate the library…

I think the answer should be fairly simple - I just don’t know what it is… I’m suspecting that I’m not correctly including the path to the underlining libraries…

I don’t want to go the AVR route - that seems like way overkill… I just want to compile the code in VS and see that it is correct.

Why not use the Arduino IDE to perform the compile?

Loath as I am to encourage anyone to use that abomination:

You'll need to have a sketch to test your library, anyway. So why not just write a simple sketch that references the library, open it in the Arduino IDE, and let it syntax-check the .cpp file(s) you created in VS? Just remember to save them in VS before you run the compile.

[quote author=Ran Talbott link=topic=52410.msg375833#msg375833 date=1298000882] Loath as I am to encourage anyone to use that abomination: [/quote]

I definitely hear that. As old and outdated as it is I still love blood shed c for coding.

AvrStudio4 isn't all that much overkill. It's only about 30mb bigger than the arduino ide. AvrStudio4Setup.exe - 116mb installer file - 85.5MB

Thanks all/Ran... I was doing what you suggested, I just figured there was a better way... It becomes harder when the code blows up on the arduino side and I have to go upstream and find out what went wrong in the library...

If you are using any visual studio version other than express then you can use the free Visual Micro addin for Visual Studio. The addin allows us to program, compile and upload to any arduino microcontroller using Visual Studio.