Pages: [1]   Go Down
Author Topic: Visual Studio 2010 external editor  (Read 2682 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}
 
 #endif


Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can anybody help?
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
int main(void)
{
init();
setup();
   
for (;;)  loop();
       
return 0;
}


An alternative might be to look closer at this project:

http://www.visualmicro.com/
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 17, 2011, 10:08:26 am by hexskrew » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not use the Arduino IDE to perform the compile?
Logged

Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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*
arduino-0022.zip - 85.5MB
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Offline Offline
Full Member
***
Karma: 11
Posts: 165
IDE for Microsoft Visual Studio and Atmel Studio 6.1, optional USB Debugger
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Read more... http://www.visualmicro.com/
Logged

Arduino for Microsoft Visual Studio Pro and Atmel Studio 6.1 http://www.visualmicro.com
Arduino Debugger http://www.visualmicro.com/post/2012/05/05/Debug-Arduino-Overview.aspx

Pages: [1]   Go Up
Jump to: