Thread: weird errors gcc: functions like floor(), ceil(), sqrt()

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    91

    weird errors gcc: functions like floor(), ceil(), sqrt()

    hi!

    I just recently started working in linux red hat 9.0 to compile my C programs , I am using the gcc command but the program is giving me weird errors and does not recognize the functions ceil(), floor() and sqrt(), I have tried and added most header files like math.h nad stdlib.h along with stdio.h but I keep getting wried errors like :


    /tmp/ccqz1JFE.o(.text+0xba): In function `main':
    : undefined reference to `sqrt'
    collect2: ld returned 1 exit status


    The program is as follows


    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    
    int main()
    {
    	double i, j, k;
    	for(j = 0.0; j < 1.0; j += 0.1)
    		printf("%8.1f", j);
    	printf("\n");
    	for(i = 0.0; i < 10.0; i += 1.0)
    	{
    		for(j = 0.0; j < 1.0; j += 0.1)
    		{
    			k = i + j;
    			printf("%8.1f", sqrt(k));
    		}
    		printf("\n");
    	}
    	return 0;
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Don't cross-post, it's rude. A lot of us read all of the forums, so cross-posting will likely be counter productive. Instead of getting you a faster response, we might just ignore you.
    My best code is written with the delete key.

  3. #3

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird errors...
    By dug in forum Windows Programming
    Replies: 5
    Last Post: 06-27-2003, 01:09 PM
  2. Replies: 2
    Last Post: 05-23-2003, 02:46 PM
  3. weird compile errors
    By Leeman_s in forum C++ Programming
    Replies: 2
    Last Post: 01-02-2003, 10:51 PM
  4. Weird /. errors
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-12-2002, 08:50 AM
  5. Visual C++ and friend functions giving errors
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 11-04-2001, 06:55 PM