cancel
Showing results for 
Search instead for 
Did you mean: 

Linking new added h and c files to the project

ksale.1
Senior

I've created h and c files in Inc and Src folders, I get the following error: "undefined reference to `ILI9341_DrawPixel'

*.h file:

void ILI9341_DrawPixel(uint16_t x,uint16_t y,uint16_t color);

*.c file:

while (x >= y)

{

ILI9341_DrawPixel(X + x, Y + y, color);

ILI9341_DrawPixel(X + y, Y + x, color);

ILI9341_DrawPixel(X - y, Y + x, color);

ILI9341_DrawPixel(X - x, Y + y, color);

.......

undefined reference to `ILI9341_DrawPixel'

Best regards

1 ACCEPTED SOLUTION

Accepted Solutions

Where is the ILI9341_DrawPixel() function's body? Use Find-in-File or grep (equivalent) to track it down. Include files don't provide code, just interface details.

ILI9341_GFX.c ?

https://github.com/martnak/STM32-ILI9341/blob/master/Src/ILI9341/ILI9341_STM32_Driver.c#L404

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

Expect that you will need to #include the .H

If those are in current include paths the compile should find them.

Source behind the functions needs to be added via the project tree view.

The error is coming from the Compiler or the Linker?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ksale.1
Senior

Hi @Community member​ , you're always there for our rescue. Please note the following:

1- Expect that you will need to #include the .H -> included

2- If those are in current include paths the compile should find them. -> in the path

0693W00000NskKvQAJ.png 

3- Source behind the functions needs to be added via the project tree view.-> yes

0693W00000NskK2QAJ.png4- The error is coming from the Compiler or the Linker? -> error message:

d:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/ILI9341_STM32_Driver.o: in function `ILI9341_DrawHollowCircle':

D:/slntcPrjct/small_spi_tft/Debug/../Core/Src/ILI9341_STM32_Driver.c:23: undefined reference to `ILI9341_DrawPixel'

Where is the ILI9341_DrawPixel() function's body? Use Find-in-File or grep (equivalent) to track it down. Include files don't provide code, just interface details.

ILI9341_GFX.c ?

https://github.com/martnak/STM32-ILI9341/blob/master/Src/ILI9341/ILI9341_STM32_Driver.c#L404

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ksale.1
Senior

You've nailed it...My mistake ... I've copied the wrong body of "ILI9341_STM32_Driver.c" that together with adding the "ILI9341_GFX.c" everything compiled successfully.