Undefined Reference error : After separation of classes

I’m trying to separate Header file, C++ classes and main class.

When working in the same directory that is the src everything works perfectly fine(All classes in one place).
However, if I try to split classes(move Header files to include folder and c++ classes to **lib folder **. I am getting undefined reference.

I have read similar thread people were encouraged to add all the classes in src directory.

Does this issue has a solution or the best is to add all the files in one folder src

Below is the error that I’m getting

Linking .pio/build/uno/firmware.elf
/var/folders/tl/l4jm4xs90xdcpbx0_6vhfb3h0000gn/T//ccBKtLdi.ltrans0.ltrans.o: In function global constructors keyed to 65535_0_main.cpp.o.1804': <artificial>:(.text.startup+0x68): undefined reference toRobot::Robot(int, int, int)’
/var/folders/tl/l4jm4xs90xdcpbx0_6vhfb3h0000gn/T//ccBKtLdi.ltrans0.ltrans.o: In function main': <artificial>:(.text.startup+0xfc): undefined reference toRobot::normalTrafficFlow()’
collect2: error: ld returned 1 exit status
*** [.pio/build/uno/firmware.elf] Error 1

Yes, because you are violating the needed folder structure it seems? platform-atmelavr/examples/arduino-blink/lib/README at develop · platformio/platform-atmelavr · GitHub. If you create a new “library” and put the header in your project’s include folder but the source code of the library in the library folder, this breaks their linkage.

Either create a new folder in lib in which you place both .h and .cpp files (if it’s supposed to be reusable code and has no direct dependencies on any of the code found in include and src) or put it in src and include.

Thanks, maxgerhardt… I have moved all the files(.h and .cpp files) to either lib directory or include directory and it’s perfectly working.

Is it possible to have all the Header files(.h) in include directory and all Source files(.cpp) in lib directory ?

My Google Foo must be strong tonight because I have been trying to figure out the undefined reference error for a week or so and I found this thread on the first try. I am migrating to PlatformIO from Arduino IDE and with advanced tools come advanced error messages. Which are followed by a Google search.
This issue arose for me when I tried to use a Library from my Arduino libraries folder. I tried putting the .cpp file into the Lib folder and the .h file in the include folder. Error. But if you think how the Arduino Libraries are structured, it makes sense that both .cpp & .h go in the same folder (a subfolder for instance) in the Lib folder. Why I couldn’t figure that one out myself is another mystery.
Thanks to @malvern for the nudge in the right direction.