bjohnsonfl / Madgwick_Filter

A quaternion based sensor fusion algorithm that fuses accelerometers and gyroscopes and optionally magnetometers
MIT License
136 stars 17 forks source link

"Undefined reference" errors re: math library functions #2

Closed sincak closed 5 months ago

sincak commented 1 year ago

Standard math library needs to be linked after compilation (makefile needs to be updated so gcc is called with -lm option).

Epoch2022-iOS commented 7 months ago

Hello, it's can be used for Android Device? pls. help me understand it

EricXu1728 commented 6 months ago

Standard math library needs to be linked after compilation (makefile needs to be updated so gcc is called with -lm option).

To follow up, CMakeList should be updated to something like so:

cmake_minimum_required(VERSION 3.11)

project(Madgwick_Filter)

# Should be in a subdirectory 
add_library(madgwick SHARED madgwickFilter.c)

target_include_directories(madgwick PUBLIC ${PROJECT_SOURCE_DIR}/)

add_executable(${PROJECT_NAME} main.c)

# Link the math library for the executable
target_link_libraries(${PROJECT_NAME} 
    madgwick
    m  # Link with the math library
)
bjohnsonfl commented 6 months ago

Should be fixed with latest commit.

bjohnsonfl commented 5 months ago

Issue closed