Develop library locally

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.

My questions:

  1. Can a library be develop this way ?
    I followed this YouTube as a reference #71 How to create an Arduino Library - easy!

  2. 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");
}

File OwiNet.h

#ifndef  OWINET
#define  OWINET

#include "Arduino.h"

class OwiNet {
      public:
      // constructor
      OwiNet();

      // Methods
      void list();

      private:
      
};

#endif

There are many posts which deal with the error message I get in the case of "OwiNet B11Net();"

I tired to change to "OwiNet B11Net; " as suggested.
Unfortunately without success.

However , I have nod idea why this does not work as expected.

Hope someone can help to get this working.

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

The library shouldn't include the .ino file, for example OwiNet.ino

Hello UKHeliBob,

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.

Hello Edison, that's pretty clear.
If so I would put it in an example directory in the library section.

My suggestion was to put the .ino file and the library files in a folder in your normal sketchbook folder rather than somewhere else

And this should really be an example. No parts of the library code can be included in this file

I think you are talking about the arduino folder which is suggested by the IDE.
I have just tired this. The compile errors remain the same.

Please show the error message in full

Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

C:\Users\kempe\Documents\Arduino\OwiNet\OwiNet.ino: In function 'void loop()':

OwiNet:23:10: error: request for member 'list' in 'B11Net', which is of non-class type 'OwiNet()'

B11Net.list();

      ^~~~

exit status 1

request for member 'list' in 'B11Net', which is of non-class type 'OwiNet()'

Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.

Loose the braces, you are declaring a function that returns an OwiNet object,
not defining an object.

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.

There is no member/methode named list.

if you edited something - show the new code

use

void OwiNet::list() {
  Serial.println("Networklist");
}

File OwiNet.cpp

void OwiNet::list() {
  Serial.println("Networklist");
}

@rwkemper
"Solution" mark should be in the @Whandall message - he was the first

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.

THANK YOU VERY MUCH

thanks for the hint, Sorry.

I think you should glance over the basic C++ class syntax,
both of the errors were grounded in a knowledge gap in that area. :wink: