Blog

Python 3.7 And 2.7 Installation Steps On Windows 10

Changing python default versions on fedora 27?

Python websockets installation is failed on fedora linux

Network Basics

Document Clustering

Clustering Techniques

SQL Injection and Prevention Techniques

Google Form Intro and App Scripts

Download in Youtube using Youtube-dl commands

Java Network Launch Protocol File Launch Issue

javaws command is not working

Forcing Website with HTTPS instead of HTTP

Cricket Scores API's

Design Patterns

IIS Installation and Configuration on Windows 10

Unable to start debugging on the web server (IIS Error Code 405)

Google Chrome Installation on Fedora 26, CentOS / RHEL 7.4

Install Fedora 26 On Virtual Machine Using VirtualBox in Windows 10

Using screen command in fedora 25

Java JDK 1.8 Installation Steps On Windows 10

Enable Permanent SSH Access on Linux

C Program Undefined Reference Error

Curl error and couldn't resolve hostname fedora mirrors

Installing Android Studio in Windows 10

Resetting Root password on Fedora 26

Installing visual studio code editor steps for fedora 27 / centos 7 / RHEL 7

Java JNI Error UnsupportedClassVersionError in Windows 10

Install virt-customize in RHEL 8

Updating qcow2 image in RHEL 8

Remove the files from dir in another dir

Install virtualenv in RHEL 7

Install Scapy in RHEL 7

SQL ACID properties

undefined reference issue in C program



C Program Undefined Reference Issue

Why C program throws undefined reference error?

C programs are used to find the square root value, and throws undefined reference error when compiling the code.

sqrt math function

#include                                                                
#include                                                               
                                                                                
void main()                                                                     
{                                                                               
 float sqrtval, val;                                                            
 val =25.0;                                                                     
 sqrtval = sqrt(val);                                                           
 printf("sqrt of 25 is %f", sqrtval);                                           
}     
Output:
$ cc sqrt-val.c
/tmp/cciHGLUh.o: In function `main':
sqrt-val.c:(.text+0x1b): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status

pow math function

#include                                                                
#include                                                               
                                                                                
void main()                                                                     
{                                                                               
 float sqrtval, val;                                                            
 val =25.0;                                                                     
 sqrtval = pow(val,0.5);                                                        
 printf("sqrt of 25 is %f", sqrtval);                                           
}  
Output:
$ cc sqrt-val.c
/tmp/ccpqCkS1.o: In function `main':
sqrt-val.c:(.text+0x23): undefined reference to `pow'
collect2: error: ld returned 1 exit status

To resolve this issue, we need to use -lm when compiling the code using either cc or gcc compiler.

$ cc sqrt-val.c -lm
$ ./a.out 
sqrt of 25 is 5.000000
or
$ gcc sqrt-val.c -lm
$ ./a.out 
sqrt of 25 is 5.000000

 Blog

Python 3.7 And 2.7 Installation Steps On Windows 10

Changing python default versions on fedora 27?

Python websockets installation is failed on fedora linux

Network Basics

Document Clustering

Clustering Techniques

SQL Injection and Prevention Techniques

Google Form Intro and App Scripts

Download in Youtube using Youtube-dl commands

Java Network Launch Protocol File Launch Issue

javaws command is not working

Forcing Website with HTTPS instead of HTTP

Cricket Scores API's

Design Patterns

IIS Installation and Configuration on Windows 10

Unable to start debugging on the web server (IIS Error Code 405)

Google Chrome Installation on Fedora 26, CentOS / RHEL 7.4

Install Fedora 26 On Virtual Machine Using VirtualBox in Windows 10

Using screen command in fedora 25

Java JDK 1.8 Installation Steps On Windows 10

Enable Permanent SSH Access on Linux

C Program Undefined Reference Error

Curl error and couldn't resolve hostname fedora mirrors

Installing Android Studio in Windows 10

Resetting Root password on Fedora 26

Installing visual studio code editor steps for fedora 27 / centos 7 / RHEL 7

Java JNI Error UnsupportedClassVersionError in Windows 10

Install virt-customize in RHEL 8

Updating qcow2 image in RHEL 8

Remove the files from dir in another dir

Install virtualenv in RHEL 7

Install Scapy in RHEL 7

SQL ACID properties

Privacy Policy  |  Copyright@2017 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^