While using sqrt (n) with any variable n I am getting an error undefined reference to sqrt.
            Asked
            
        
        
            Active
            
        
            Viewed 65 times
        
    -5
            
            
        - 
                    Because you didn't include `-lm` on the link line after the object file name. On some systems, you have to specify `-lm` to link the maths library, which is where `sqrt()` is kept. Other systems do not need the separate maths library; the maths functions are in the main C library. – Jonathan Leffler Dec 13 '14 at 17:02
- 
                    Did you include `#include` ? – Rizier123 Dec 13 '14 at 17:02
- 
                    1Please, show the example. – nbro Dec 13 '14 at 17:02
1 Answers
-1
            
            
        You should use #include <math.h>.
If you are using C++ use #include <cmath>.
 
    
    
        Jonathan Leffler
        
- 730,956
- 141
- 904
- 1,278
 
    
    
        Lucas Cavalcante
        
- 1
- 1
- 
                    The question is explicitly tagged C. The problem is a linker problem, not a compiler problem. – Jonathan Leffler Dec 13 '14 at 17:05
