I am trying to compile a sketch with some additional c language files in the same directory. The compile and ld seems to miss the extra files.
How do I fix that?
Here is a directory listing from the directory containing my
$ ls -1
flexpwm_auxiliary.c
flexpwm_auxiliary.h
LCCD_Controller_250514.ino
And here is the output from the compile and link,
/home/nelson/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/nelson/.cache/arduino/sketches/4636C8904CF489ED832AFE7140B4A5E6/sketch/LCCD_Controller_250514.ino.cpp.o: in function `loop':
/home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/LCCD_Controller_250514.ino:3211: undefined reference to `pwm_baseaddr(unsigned char)'
/home/nelson/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/LCCD_Controller_250514.ino:3212: undefined reference to `pwm_submodule(unsigned char)'
/home/nelson/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/LCCD_Controller_250514.ino:3213: undefined reference to `pwm_channel(unsigned char)'
collect2: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
Thank you, that works. But now my Serial.print() inside of the .c file, are undefined.
Is there an easy fix for that?
/home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/flexpwm_auxiliary.c: In function 'printbits16_':
/home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/flexpwm_auxiliary.c:161:5: error: 'Serial' undeclared (first use in this function)
161 | Serial.print((u16>>bits)&1);
| ^~~~~~
/home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/flexpwm_auxiliary.c:161:5: note: each undeclared identifier is reported only once for each function it appears in
/home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/flexpwm_auxiliary.c: In function 'pwm_dump':
/home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/flexpwm_auxiliary.c:182:3: error: 'Serial' undeclared (first use in this function)
182 | Serial.print("PWM pin");
| ^~~~~~
/home/nelson/Projects/TeensyDataAcquistion/SPI_Instrumenation_Project/Firmware/LCCD_Controller_250514/flexpwm_auxiliary.c:200:57: error: 'BIN' undeclared (first use in this function)
200 | Serial.print( "MCTRL2 MONPLL "); Serial.print(u16&0XF,BIN);
| ^~~
exit status 1
Compilation error: 'Serial' undeclared (first use in this function)
Here are the .c and .h files. This is meant to add some functionality to the Teensy 4 pwm support, to facilitate low level access to the PWM registers.
So... I found the cache and manually deleted it. There must be some way to do this in a more organized or systematic way in the IDE.
If it is necessary to delete the cache when files are renamed, would that not seem to qualify as a bug or design error? It is certainly a foreseeable use case.
Please only comment on the GitHub issue thread if you have new technical information that will assist with the resolution. General discussion and support requests are always welcome here on the Arduino Forum.