# undefined reference to `sqrt' / `pow' / `sin' — missing -lm

**Code:** `undefined reference to sqrt` · **Category:** C/C++ · **Seen on:** C/C++, Linux

The math library is not linked, so libm functions are unresolved.

## Meaning

On Linux with GCC, libm is separate from libc. Put `-lm` after the object files.

## Common causes

- `-lm` missing
- `-lm` placed before the sources

## Quick fix

1. Add `-lm` at the end of the command
2. In CMake use `target_link_libraries(app m)`

## Detailed fix by platform

### GCC

1. `gcc main.c -o app -lm`

## How to diagnose

1. **Order** — -lm after sources?
2. **Recent change** — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cpp/undefined-reference-math-sqrt)
