Skip to content

Add math.h in Motors.lf due to pico-sdk version changes.#9

Merged
Jakio815 merged 1 commit intolf-lang:mainfrom
Jakio815:main
Aug 21, 2025
Merged

Add math.h in Motors.lf due to pico-sdk version changes.#9
Jakio815 merged 1 commit intolf-lang:mainfrom
Jakio815:main

Conversation

@Jakio815
Copy link
Copy Markdown
Collaborator

@Jakio815 Jakio815 commented Aug 21, 2025

The Motors.lf requires math.h to be included. Looks like this happened due to pico-sdk version changes.

[ 75%] Built target robot
[ 75%] Building C object CMakeFiles/RobotDriveSolution.dir/lib/schedule.c.o
[ 75%] Building C object CMakeFiles/RobotDriveSolution.dir/_robotdrivesolution_main.c.o
[ 76%] Building C object CMakeFiles/RobotDriveSolution.dir/_motors.c.o
[ 76%] Building C object CMakeFiles/RobotDriveSolution.dir/RobotDriveSolution.c.o
[ 76%] Building C object CMakeFiles/RobotDriveSolution.dir/_robot.c.o
[ 76%] Building C object CMakeFiles/RobotDriveSolution.dir/Users/dkim314/project/temp/pico-sdk/src/rp2_common/pico_stdlib/stdlib.c.o
[ 76%] Building C object CMakeFiles/RobotDriveSolution.dir/_display.c.o
[ 77%] Building C object CMakeFiles/RobotDriveSolution.dir/Users/dkim314/project/temp/pico-sdk/src/rp2_common/hardware_gpio/gpio.c.o
/Users/dkim314/project/temp/src/lib/Motors.lf: In function '_motors_method_set_power':
/Users/dkim314/project/temp/src/lib/Motors.lf:32:13: error: implicit declaration of function 'fabsf' [-Wimplicit-function-declaration]
   32 |     power = fabsf(power);
      |             ^~~~~
/Users/dkim314/project/temp/src/lib/Motors.lf:32:1: note: include '<math.h>' or provide a declaration of 'fabsf'
   31 |   method set_power(power: float, forward: bool, left: bool) {=
  +++ |+#include <math.h>
   32 |     power = fabsf(power);
make[2]: *** [CMakeFiles/RobotDriveSolution.dir/build.make:121: CMakeFiles/RobotDriveSolution.dir/_motors.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:2361: CMakeFiles/RobotDriveSolution.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
lfc: error: CMake failed with error code 2
lfc: error: Compilation was unsuccessful.
lfc: fatal error: Aborting due to 2 previous errors.

I just added this one line #include <math.h> in src/motors.lf

@hokeun hokeun self-requested a review August 21, 2025 00:36
@Jakio815 Jakio815 merged commit b93c079 into lf-lang:main Aug 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants