Test returns "undefined reference" to the tested class - linkage error?

Hi all,
I’ve searched the forum (and Google), but can only find others with the same error, but not the same problem. The complete error output is here. and the test code is here. I’m using PlatformIO Core 5.0.3 in VSCode and I’m working with a Teensy 3.2. The codebase works well, but when running the test, the linker complains:

undefined reference to S1000::CommandPackager::CommandPackager()'`

It also complains multiple times for the same file and all uses of it. It seems likely that the test setup cannot find this file despite it being in my projects “src” folder, but the error message does not give me much to work with.

This is my first test in PlatformIO, so it’s extremely likely that I’ve done something very dumb, but I’ve been trying getting this to work for over an hour, so any pointers would be much appreciated! :wink:

Note: Could it be that the testing setup does not understand Namespaces?

PlatformIO won’t build the sources in src unless you tell it to using the documented test_build_project_src = yes option in platformio.ini. But then you also need to make sure that no other file defines setup() and loop(), so you have to do as documented (the #2 option) to prevent that. However, also consider option number 1 as layed out in the documention: Put the code / components to be tested into lib/ as their seperate thing.

1 Like

Thanks @maxgerhardt!
I knew it was something simple like this. I’ll move this to option 1 as my codebase matures. This works well enough for now :slight_smile: