Dear All,
I try to create a library for my own. I want to develop it on some dev directory first.
At my PC the directory is: C:\Users............\IT_Projekte\Dev\OwiNet.
Theere I created my OwiNet.h , OwiNet.cpp and a OwiNet.ino as well. The .cpp and .h files with help of the IDE ( litte triangle drop down on the very right)
After debug and test is finished I want to move it to the arduino library folder.
I'm using Arduino IDE 1.8.19
My traget device is a nano or pro mini. At present I have selected nano in the IDE.
I get compilation errors I don't understand. Please refer to the OwiNet.ino comment.
File OwiNet.ino
#include "OwiNet.h"
//TRIAL 1
OwiNet B11Net();
// leads to "OwiNet:20:10: error: request for member 'list' in 'B11Net',
// which is of non-class type 'OwiNet()'"
// B11Net.list();
// ^~~~
// TRIAL 2
//OwiNet B11Net; // this did not help,
// leads to "........IT_Projekte\Dev\OwiNet/OwiNet.ino:14:
// undefined reference to `OwiNet::list()'"
void setup() {
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Start Output");
B11Net.list();
delay(1000);
}
File OwiNet.cpp
#include "OwiNet.h"
OwiNet::OwiNet() {
// init code should be here
}
void list() {
Serial.println("Networklist");
}
Why not develop the library in the same folder as the sketch used to test it and use quotation marks around the .h filename to ensure that the local copy of the library is used
When the library is finalised, move it to the Arduino libraries folder and the same syntax will pick it up from there
may be I missundestood your answer. Sofar all files (.ino,.h,.cpp) are in the same directory. I think I have also used double quotes for the include names.
The compiler also does not complain any include.
This is what I tried already.
Did it again. Here are the errors
C:\Users\kempe\AppData\Local\Temp\ccfms6YN.ltrans0.ltrans.o: In function loop': C:\Users\kempe\Documents\Arduino\OwiNet/OwiNet.ino:23: undefined reference to OwiNet::list()'
collect2.exe: error: ld returned 1 exit status
exit status 1
Fehler beim Kompilieren für das Board Arduino Nano.
Wow, thank you for all the fast replies and suggestions.
Finally, I needed both:
the instanciation OwiNet B11Net in the .ino , because the class has no parameters
and void OwiNet::list() in cpp to make it a member of the class.
In essense, the approch to create a lib locally can be done the way I did it now.
Any directory will do.