Structur problem or Linker problem?

Hey,

i was given the task to write unit test for a code which was written with the platformIO IDE. i am new to this IDE but in most cases it similar to others (i hope).
My issue is that if i write the unit test in the test folder and want to include a hpp file from the src it will throw the undefined reference to function error in the buidl process. Which why i read the documents to platformIO there it is written, that the src is not included in the build process when unit test are build, which why it is suggested to use the lib directory. Here i put all the written hpp and cpp files into a seperated folder and src supfolder. This worked out fine for the unit test now the linker found the included files. But when i build the source code itself for the esp it come up with some issue like fatal error: xxx.hpp: no such file or directory.

If i copy the included files directly into the test folder it works as well but not if i have everything in the src folder itself, even if i include the directory in the platformio.ini directly.

Did i missunderstood something? This seems to complicated to be right if i always have to rearrange the structer or copy the updated files which shall be tested into the test folder.

Since you changed the location of your header files from the src to the lib folder: Did you also change the include statements from a local include (#include "mylib.hpp") to a global include (#include <mylib.hpp>) ?

Thanks for the quick response. Oh yeah it seems that is the thing i might have missed. It is build it now

1 Like