The library that you are using needs to be placed after the files that use it when you are using it from the command line. So place -lm
on after your C files on the command line.
More Related Contents:
- Running C — helloWorld runs but nothing else — Ubuntu
- Why does the order of ‘-l’ option in gcc matter? [duplicate]
- Undefined reference to ‘pthread_create’ — linker command option order (libraries before/after object files?) [duplicate]
- How to make weak linking work with GCC?
- gcc will not properly include math.h
- Can I mix static and shared-object libraries when linking?
- `bash: ./a.out: No such file or directory` on running executable produced by `ld`
- Linking against older symbol version in a .so file
- What is the default C -std standard version for the current GCC (especially on Ubuntu)?
- Linking a C program directly with ld fails with undefined reference to `__libc_csu_fini`
- How to link to a different libc file?
- getrandom syscall in C not found
- Query on -ffunction-section & -fdata-sections options of gcc
- log(10.0) can compile but log(0.0) cannot with undefined reference?
- Modulo operation with negative numbers
- Order of local variable allocation on the stack
- What is the meaning of lines starting with a hash sign and number like ‘# 1 “a.c”‘ in the gcc preprocessor output?
- aligned malloc() in GCC?
- How to access C variable for inline assembly manipulation?
- Detecting 64bit compile in C
- How to make gcc link strong symbol in static library to overwrite weak symbol?
- C preprocessor: expand macro in a #warning
- Multiple definition of … linker error
- Why “initializer element is not a constant” is… not working anymore?
- GCC 4.7 Source Character Encoding and Execution Character Encoding For String Literals?
- Tool to analyze size of ELF sections and symbol
- C code with undefined results, compiler generates invalid code (with -O3)
- Produce loops without cmp instruction in GCC
- What exactly is -fno-builtin doing here?
- Integer overflow in C: standards and compilers