'Undefined Reference' in unit test project

1.8k Views Asked by At

I am using TinyEmbeddedTest and VisualGDB in Visual Studio 2015, and attempting to create a unit test project as part of my solution. My main project builds and runs fine, but the unit test project is getting linker errors and will not build.

The tests are in a source file, ADCTests.cpp, which has

#include “ADC.c”

Which I believe is appropriate for TinyEmbeddedTest.

The file ADC.c contains the following include lines:

#include “ADC.h”
#include “fault.h”

The errors are thrown in ADC.c, on the following statements:

if (status == SUCCESS)
{
Fault_Clear(FAULT_ADC_FAILURE);
rawADCValue = HAL_ADC_GetValue(hADC);
}
else
{
Fault_Set(FAULT_ADC_FAILURE);
rawADCValue = 0u;
}

The errors are:

undefined reference to ‘Fault_Clear’

undefined reference to ‘Fault_Set’

From this I can see that the header file, fault.h, where these functions are declared, is accessible to the toolchain, because otherwise there would be a compilation error, but the source file. fault.c, where these functions are defined, does not seem to be accessible. Both of these files are in the same project.

I do not get these errors when running my main project, only in the unit test project.

I thought that perhaps the answer might lie in the project linker settings, and so I added a line to the Linker->[Additional Inputs] as follows:

C:\Development\myProject\VisualGDB\Debug\Src

I assumed that this would give the linker access to the .o files, created by the compiler. Unfortunately this created a new problem. The build now fails without any error messages. The list of build messages simply says

Build failed: arm-none-eabi-g++.exe exited with code 1 Id returned 1 exit status

and when I look at the log, it says

c:/sysgcc/arm-eabi/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find C:/Development/myProject/VisualGDB/Debug/Src: Permission denied

Interestingly, that last path is a hyperlink, and when I click on it, I get an error dialog box

Failed to open ‘C:\SysGCC\arm-eabi\Development\myProject\VisualGDB\Debug\Src’

This is especially odd, because I know that path does not exist, and that is definitely not the path that I entered in the Linker settings.

Any guidance would be much appreciated.

0

There are 0 best solutions below