CMAKE_CXX_FLAGS are flags for the C++ compiler. -l is a linker flag. To link to a library, use this:

target_link_libraries(alfa_1 m)

You might also want to replace -std=c11 with use of CMAKE_C_STANDARD and related variables (CMAKE_C_STANDARD_REQUIRED, CMAKE_C_EXTENSIONS), and possibly replace use of CMAKE_CXX_FLAGS with a call to target_compile_options().

Answer from Angew is no longer proud of SO on Stack Overflow
🌐
LinuxQuestions.org
linuxquestions.org › questions › programming-9 › c-program-error-undefined-reference-to-pow-4175698172
C Program error : undefined reference to pow
July 22, 2021 - I typed a C program from the Internet that calculates Compound Interest. One of the lines in the program reads CIFuture = PAmount*(pow((1+ROI/100),
Discussions

gcc - Undefined reference to pow( ) in C, despite including math.h - Stack Overflow
Possible Duplicate: Problem using pow() in C what is 'undefined reference to `pow'' I'm having a bit of an issue with a simple piece of coursework for uni that's really puzzling me. Essentially, I'... More on stackoverflow.com
🌐 stackoverflow.com
c - Undefined reference to `pow' and `floor' - Stack Overflow
I'm trying to make a simple fibonacci calculator in C but when compiling gcc tells me that I'm missing the pow and floor functions. What's wrong? Code: #include #include More on stackoverflow.com
🌐 stackoverflow.com
link error: undefined reference to `pow'
There was an error while loading. Please reload this page · Ubuntu 16.04.4 LTS gcc version 5.4.0 More on github.com
🌐 github.com
4
July 30, 2019
undefined reference to `pow'
Link with the math library. -lm More on reddit.com
🌐 r/cpp_questions
7
0
April 19, 2022
🌐
IncludeHelp
includehelp.com › c-programming-questions › error-undefined-reference-to-pow-in-linux.aspx
Error - undefined reference to 'pow' with C program in GCC Linux
C - Call by Reference Vs. Call by Value ... C Vs. Embedded C ... C - Copy Two Bytes Int. to Byte Buffer ... This is a common error while compiling C program in GCC/G++ Linux. This error occurs when you are using pow function to calculate power of a number in your programs.
🌐
Cprogramming
cboard.cprogramming.com › c-programming › 79669-undefined-reference-pow-sqrt-even-though-math-h-header-there.html
"Undefined Reference" to pow and sqrt even though math.h header is there
June 1, 2006 - #include <stdio.h> #include <math.h> double hypotenuse(double a, double b); int main() { double side1, side2; printf("Enter side 1: "); scanf("%lf", side1); printf("Enter side 2: "); scanf("%lf", side2); printf("%.2f\n", hypotenuse(side1, side2) ); return 0; } double hypotenuse(double a, double b) { return sqrt( pow(a, 2) + pow(b, 2) ); } ... If you're using gcc as your compiler, try adding -lm to the end of your compile line to link in the math library. If you understand what you're doing, you're not learning anything. ... > scanf("%lf", side1); And don't forget the & either when using scanf gcc -W -Wall -ansi -pedantic -O2 foo.c Tells you when you make a mess of printf/scanf conversions (amongst other things) If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206607085-CLion-Enabling-math-h-for-C-projects
CLion - Enabling for C projects – IDEs Support (IntelliJ Platform) | JetBrains
August 24, 2015 - From what I know (a bit googling) math.h is not enabled by default, so a compiler raises an error: "undifined referece to pow" In order to get run I need to provide "-lm" flag (google told me so ^_^) The question is: where exactly should I write this flag in CLion?
Find elsewhere
🌐
Francisfisher
francisfisher.me.uk › problem › 2011 › undefined-reference-to-ceil-or-pow-or-floor-or-in-ubuntu-11-10
undefined reference to `ceil’ (or pow or floor or …) in ubuntu 11.10 | Computer Stuff
frankster@frankie-laptop:~> cat testm.c #include <math.h> int main(int argc, char*argv[]){ double x; double return_val = ceil(x); return 0; } frankster@frankie-laptop:~> gcc -lm testm.c /tmp/ccNkQLo6.o: In function `main': testm.c:(.text+0x15): undefined reference to `ceil' collect2: ld returned 1 exit status>
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-solve-undefined-reference-to-pow-in-c-language
How to solve undefined reference to `pow' in C language? - GeeksforGeeks
July 23, 2025 - The math library (libm) contains ... others. If you do not explicitly link this library during the compilation, the linker will not be able to find the definition of pow, resulting in an "undefined reference" error...
🌐
Bytes
bytes.com › home › forum › topic
Undefined reference to 'pow()' using <math.h> - C / C++ - Bytes
November 1, 2007 - Hi all I m using the gcc compiler, and when i tried to use pow() function it gives error like this, undefined reference to `pow'.......... ............... Then i used -lm option in right place again it gives the same error...... Plz Give me a soln........ Thanks allll..........
🌐
GitHub
github.com › hpcgarage › spatter › issues › 33
link error: undefined reference to `pow' · Issue #33 · hpcgarage/spatter
July 30, 2019 - [100%] Linking C executable spatter /spatter.dir/src/json.c.o: In function json_parse_ex': json.c:(.text+0xe2a): undefined reference to pow' json.c:(.text+0x1466): undefined reference to `pow' collect2: error: ld returned 1 exit status CMakeFiles/spatter.dir/build.make:233: recipe for target 'spatter' failed ·
Author   john-wilkes
🌐
Reddit
reddit.com › r/cpp_questions › undefined reference to `pow'
r/cpp_questions on Reddit: undefined reference to `pow'
April 19, 2022 -

Hello! I have a very strange problem.

code:

#include <stdio.h>
#include <math.h>
int main() {
long long a = 1, b = 2;

double ans = pow(1, 2);

printf("%f", ans);
return 0;
}

--------------------------------------

return:

1.000000

============================================

code:

#include <stdio.h>
#include <math.h>
int main() {
long long a = 1, b = 2;

double ans = pow(a, b);

printf("%f", ans);
return 0;
}

--------------------------------------

return:
/usr/bin/ld: CMakeFiles/untitled.dir/main.c.o: in function \main':`

/home/tarminik/CLionProjects/untitled/main.c:7: undefined reference to \pow'`

collect2: error: ld returned 1 exit status

🌐
Ubuntu Forums
ubuntuforums.org › showthread.php
undefined reference to 'pow'
April 29, 2008 - The meeting point for the Ubuntu community
🌐
Reddit
reddit.com › r/clion › clion - undefined reference
r/clion on Reddit: CLION - undefined reference
April 26, 2021 -

Hello Guy,

I'm trying to implement Mosquitto via CLion and I'm getting this error (you could check the attached image).

PS. : I already included the header and I also added the directory of Mosquitto folder to the environment variables : C:\Program Files\mosquitto\devel...

Could you please take a look and help me out to solve this error?

Thanks in advanced

🌐
Position Is Everything
positioniseverything.net › home › undefined reference to `pow’: fixing the error
Undefined Reference to `Pow’: Fixing the Error - Position Is Everything
November 11, 2025 - As pointed out, you will trigger the undefined reference to ‘sqrt’ if your program does not import the math.h header file while you use the pow() function in C. Pow in C is part of the math.h header file.
🌐
Reddit
reddit.com › r/c_programming › "undefined reference to pow" error after including and the gcc option -lm
r/C_Programming on Reddit: "Undefined reference to pow" error after including <math.h> and the GCC option -lm
December 16, 2021 -

Hey y'all, as the title says, I'm a wee bit stuck trying to use the math.h library function "pow". Here's my code -

#include <math.h> 
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[]) {

//OMITTED CODE

size_t i;
double j;
int k;
for(i = argLen - 1, k = 0; k < argLen; i--, k++) {
	j = pow(16, i);
	deciVals[k] = deciVals[k] * j;
}

//OMITTED CODE	

return 0;

}

Despite having math.h included, and using the -lm option for the GCC, I'm still getting this error -

>gcc -lm -o output hexConverter.c
/usr/bin/ld: /tmp/ccghjuxO.o: in function `main':
hexConverter.c:(.text+0x237): undefined reference to `pow'
collect2: error: ld returned 1 exit status

Any help would be appreciated, thanks guys.

🌐
Its Linux FOSS
itslinuxfoss.com › home › how to fix the “undefined reference to ‘pow’” error
How to fix the “undefined reference to ‘pow’” error – Its Linux FOSS
July 22, 2022 - Enter this header into your C program ... that will compile the file: ... The undefined reference to pow error is invoked if we miss the <math.h> header file or the program is not compiled correctly....
🌐
GitHub
github.com › jgarff › rpi_ws281x › issues › 424
undefined reference to `pow' as of #409 · Issue #424 · jgarff/rpi_ws281x
July 24, 2020 - # github.com/rpi-ws281x/rpi-ws281x-go /usr/bin/ld: //usr/local/lib/libws2811.a(ws2811.o): in function `ws2811_set_custom_gamma_factor': /home/pi/workspace/rpi_ws281x/ws2811.c:1298: undefined reference to `pow' collect2: error: ld returned 1 exit status
Author   TwiN