3

I am learning c and I am using code::block

I have wrote this code "from ansi c book"

#include <stdio.h>
#include <stdlib.h>

float convertToCelsius(float f);

int main()
{
    int start = 0;
    int step = 5;
    int upper = 300;

    printf("%3c\t%6c\n",'F','C');
    while(start < upper){
        printf("%3d\t%6.3f\n", start, convertToCelsius(start));
        start += step;
    }



    return 0;
}

float convertToCelsius(float f){
    return (5.0/9)*(f-32);
}

when I run the code from the IDE "code::blocks" it compile and run without problems but when I compile the c file using gcc in cygwin and try to run the exe file it gives me this message

the procedure entry point __cxa_atexit could not be located in the dynamic link library C:\cygwin\home\username\convert.exe

I have search but couldn't find related direct answer

what is the problem ?

Muhammad Nour
  • 2,109
  • 2
  • 17
  • 24
  • 1
    What is the compilation line that you use to build it? – Alex Lop. Nov 25 '15 at 12:52
  • gcc convert.c -o convert.exe – Muhammad Nour Nov 25 '15 at 12:54
  • Don't learn ANSI-C anymore! That has some deprecated idioms. Learn C11 or at least C99. – too honest for this site Nov 25 '15 at 13:07
  • I am reading "C programming language by Dennis Ritchie" if the book is not up-to-date would you please recommend me another one! – Muhammad Nour Nov 25 '15 at 13:10
  • look at your error...."....in the dynamic link library C:\cygwin\home\username\convert.exe" It looks like Windows thinks that you build a library and not an executable. My recommendations; (1) if you are going to use windows, ditch Cygwin and use mingw-w64 (see http://mingw-w64.org/doku.php) (2) at least at the start ditch CodeBlocks and just use a simple text editor (i.e. notepad++) and learn to compile from the command line. (3) Ritchie's book, while good, is dated,, you may want C Primer Plus 5th Ed (Prata), which has good reviews at ACCU. – thurizas Nov 25 '15 at 13:29
  • why ditch cygwin!? I will try to compile with mingw and what compiler is being used in c primer book – Muhammad Nour Nov 25 '15 at 14:43
  • 1
    It works fine on my version of Cygiwn. My guess it that something isn't installed properly in Cygiwn. – Dom Nov 27 '15 at 19:23

0 Answers0