Menu

Using <math.h>

carlton
2008-03-23
2012-09-26
  • carlton

    carlton - 2008-03-23

    Hi, I have the Dev-C++ 5 beta 9 version 4.9.9.2. I am having problems compiling this code:

    include<math.h>

    include<stdio.h>

    int main(int argc,int **argv)

    {
    int a=3,b=4,c=5;
    float s=(a+b+c)/2;
    float area=sqrt(s(s-a)(s-b)*(s-c));

    printf(&quot;The area of a triangle with sides %d,%d,%d\n&quot;,a,b,c);
    printf(&quot;is equal to %f&quot;,area);
    getchar();
    return 0;
    

    }

    When I try to compile I get this message:
    multiple definition of main' first defined here multiple definition ofmain'
    first defined here
    multiple definition of `main'
    first defined here
    ld returned 1 exit status
    C:\Dev-Cpp\Makefile.win [Build Error] [PRG3.exe] Error 1

    I can't find anything in the Help menu which covers this. Please help!

    R/
    Carlton

     
    • cpns

      cpns - 2008-03-24

      The message makes little sense to us if you either manually edit and transcribe it or copy it from the "Compiler" tab where it gets ruthlessly filtered to the point of unintelligibility.

      To provide complete information from which it is likely we can determine the problem you need to copy & paste the text from the "Compile Log" tab. To be honest if you look there you might even solve your own problem.

      Your problem is probably that you have added multiple source files containing main() to your project. The Compile log will tell you that. In teh full log. all those "first defined here" parts will include the actual file and line number where the definition was encountered, and so make far more sense.

      Dev-C++ attempts to filter messages in the Compiler tab so you double-click on the message to go to the line in question. Unfortunately some GCC error messages such as these span multiple output lines, and the filtered output ends up making little sense.

      >>I can't find anything in the Help menu which covers this.
      No, the help menu is near useless, but more importantly to be fair, it is the help for the Dev-C++ IDE not the GCC compiler.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.