Creating Library using Existing Library (In this case SoftwareSerial)

Hi guys, recently I wanna create my own library using another library (In this case SoftwareSerial library) for the first time. This may be a simple task for you but not for me as I am still new to Arduino.

The attachment has .ino, .cpp and .h files that I have created. And the error I receive is :

Just_Testing.cpp.o:(.bss.test+0x0): multiple definition of `test’
func.cpp.o:(.bss.test+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Error compiling.

Please help. Thanks. (974 Bytes)

First, you need to read up on, and use, include guards.

Second, you should not, in a header file, actually create objects. If it is appropriate for an instance of SoftwareSerial to be created, it should be created in the source file.

The real issue is that func.cpp is compiled, creating an object called test. Then, Just_Testing.cpp is compiled (after being created from the ino file) and another object called test is created.

Only one of the cpp files should create the instance.

Understood, problem solved. Thanks PaulS.

Thanks for the guideline in helping me to improve. I am struggling in finding a suitable source and in understanding include. Will try harder.

Once again, thank you