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
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),
🌐
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
#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
Hello there ))Have a little question about math.h library.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 ...
🌐
Bytes
bytes.com › home › forum › topic
Undefined reference to 'pow()' using - Post.Byes
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.....................
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>
🌐
CyberForum
cyberforum.ru › c-beginners › thread650331.html
Undefined reference to pow() почему в университете gcc такое выдает, а дома нет? - C (СИ) - Киберфорум
Арифметические операции и ошибка Undefined reference to `pow' # include &lt;stdio.h&gt; # include &lt;math.h&gt; int main(c) { int k; float x,y,s,r,t; printf(&quot; Enter k, x , y :... 17
🌐
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

🌐
GitHub
github.com › hpcgarage › spatter › issues › 33
link error: undefined reference to `pow' · Issue #33 · hpcgarage/spatter
May 22, 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
🌐
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...
🌐
Reddit
reddit.com › r/clion › clion - undefined reference
r/clion on Reddit: CLION - undefined reference
November 15, 2019 -

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

🌐
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.

🌐
Stack Overflow
stackoverflow.com › questions › 68359935 › undefined-reference-to-pow-when-compiled-using-gcc
c - Undefined reference to pow when compiled using gcc - Stack Overflow
I am using pow function in C and included the math.h library too The following is the error that I am getting : /usr/bin/ld: /tmp/ccUkOL31.o: in function `main': a1B.c:(.text+0xf3): undefined reference to 'pow' collect2: error: ld returned 1 exit status
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
[SOLVED] Issues with Include in C / Programming & Scripting / Arch Linux Forums
My crystal ball says you're not linking in the necessary libraries, which would result in a message like "undefined reference to `pow' " (or whatever function you're trying to use). The functions declared in <stdio.h> are in libc.a, which is linked in by default; most of what's in <math.h> ...