Hello, I have just got an Arduino and i am using visual micro because i like the VS ide.
I would rather use cpp and h files over ino so i know the layout and whats happening in my code, I have three files which are bellow, they are very basic just enough to get the errors.
Compiling ‘main’ for ‘Arduino Uno’
test.cpp.o:In function TestClass::init()' test.cpp:undefined reference to Ethernet’
test.cpp:undefined reference to `Ethernet’
test.cpp:begin(unsigned char*)’
Error creating .elf
I am hoping to share some of the networking code i write between the Arduino and a windows project which is why i would rather use cpp/h for as much code as possible.
Thanks for the quick replies but none of those suggestions seem to have helped.
I have also just tried adding the folders to the VS c++ include paths and using “SPI.h” and “Ethernet.h” (and with <>) and the includes seem to have been removed from the solution, I am looking to see if they are set / imported from somewhere when i build.
I have tried both resetting VS after reloading the tool chain and i have tried making the same thing in the Arduino IDE, nothing seems to help. If i put the Ethernet code into the ino file it all works fine in both IDE's.
PhoenixNoble:
I have tried both resetting VS after reloading the tool chain and i have tried making the same thing in the Arduino IDE, nothing seems to help. If i put the Ethernet code into the ino file it all works fine in both IDE's.
Sorry my friend but i don't have any experience to make a library, so the the problem it looks like it is on include the other library in you're new library, maybe it is a command something like extern or whatever , i believe some one in the form with a better experience can help you to solve you're problem.
For Arduino you must include libraries that you want to reference in cpp files in the [sketch].ino
You should also use "Project>Add/Import Sketch Library" to add the #includes until you understand the Arduino syntax.
Setting any VS C++ properties will not help because Visual Micro performs the same compile as the Arduino Ide which does not make use of any Visual Studio C++ properties.
Please also use the visualmicro.com form for support because this forum is for the Arduino Ide
For what it is worth I had this same error and it was because my ino file had the same filename as my entry point cpp and h files.
For example, when I had AstroEQ.cpp, AstroEQ.h and AstroEQ.ino I got the unable to create .elf file error.
After I renamed AstroEQ.cpp and AstroEQ.h to AstroEQMain.cpp and AstroEQMain.h respectively then the VSS solution built correctly. Of course I also had to update any references to the header file throughout the rest of the code.
An alternative is to rename the ino file. But then you must also make sure that the containing directory is also renamed. It would seem that the directory and the ino must have the same name.