Hi, I’m trying to get things working with my .h and .c library files but I get this compile error:
Executing task: C:\Users\Paul\.platformio\penv\Scripts\pio.exe run <
Processing ATmega4809_pyupdi_upload (platform: atmelmegaavr; board: ATmega4809)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/ATmega4809.html
PLATFORM: Atmel megaAVR (1.4.0) > ATmega4809
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 48KB Flash
PACKAGES:
- toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Paul-Lib-4809>
Building in release mode
Compiling .pio\build\ATmega4809_pyupdi_upload\src\main.o
Compiling .pio\build\ATmega4809_pyupdi_upload\libd29\Paul-Lib-4809\testRoutines.o
Archiving .pio\build\ATmega4809_pyupdi_upload\libd29\libPaul-Lib-4809.a
Linking .pio\build\ATmega4809_pyupdi_upload\firmware.elf
C:\Users\Paul\AppData\Local\Temp\cchM6JTy.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x4): undefined reference to `routine1(int)'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\ATmega4809_pyupdi_upload\firmware.elf] Error 1
================================================================================================== [FAILED] Took 1.01 seconds ================
My project folder is :
C:\Users\Paul\Documents\PlatformIO\Projects\USART-Example-4809
I followed the PIO library readme for the directory structure which is:
C:\Users\Paul\Documents\PlatformIO\Projects\USART-Example-4809\lib\Paul-Lib-4809\src
and my .h header and .c definitions exist in this directory. The files are just very basic forward definitions and function definitions:
testRoutines.h :
// header for testRoutines
#pragma once
int routine1(int x);
int routine2(int y);
and the function definitions :
testRoutines.c
int routine1(int x)
{
x++;
return x;
}
int routine2(int y)
{
y++;
return y;
}
in Main.cpp I have:
#include "testRoutines.h"
and also in Main.cpp (its a microchip USART code example to which I’ve added a function call to routine1
int main(void)
{
int val=1;
int myresult;
myresult = routine1(val);
USART1_init();
while (1)
{
USART1_sendString("Hello World!\r\n");
_delay_ms(500);
}
}
I guess i’ve fouled up on the directory structure.
Thanks for help with this,
Paul