Thread: collect2.exe: error: ld returned 1 exit status

  1. #1
    Registered User
    Join Date
    May 2014
    Location
    Turkey
    Posts
    11

    Question collect2.exe: error: ld returned 1 exit status

    Hi everyone. I have a problem about C programming. I am beginner so I will be very happy if you help me with simple and easy understandable methods.





    C:\C alıştırma>gc *.o -lm
    'gc' is not recognized as an internal or external command,
    operable program or batch file.


    C:\C alıştırma>gcc *.o -lm
    c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/libmingw32.a(main.
    o): In function `main':
    e:\p\giaw\src\pkg\mingwrt-4.0.3-1-mingw32-src\bld/../mingwrt-4.0.3-1-mingw32-src
    /src/libcrt/crt/main.c:91: undefined reference to `WinMain@16'
    collect2.exe: error: ld returned 1 exit status


    C:\C alıştırma>

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    This means you forgot to include a main function anywhere in your program. If you're a beginner and using gcc from the command line, you might try starting with a gcc tutorial that explains some basic things about using it. For example,

    GCC and Make - A Tutorial on how to compile, link and build C/C++ applications

  3. #3
    Registered User
    Join Date
    May 2014
    Location
    Turkey
    Posts
    11
    Thanks a lot for your answer. Can you help me about this problem? When I sent ''gcc -S cevre_hesapla.c'' command, I saw these errors. (at the bottom)
    Code:
    typedef long long __time64_t;
    # 60 "c:\\mingw\\include\\sys\\types.h" 3
    typedef __time64_t time_t;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    typedef long _off_t;
    
    
    typedef _off_t off_t;
    
    
    
    
    
    
    
    
    
    
    typedef long long _off64_t;
    
    
    typedef long long off64_t;
    
    
    
    
    
    
    
    
    
    
    typedef unsigned int _dev_t;
    
    
    
    
    typedef _dev_t dev_t;
    
    
    
    
    
    
    
    
    
    
    
    
    typedef short _ino_t;
    
    
    
    
    typedef _ino_t ino_t;
    
    
    
    
    
    
    
    
    
    
    
    
    typedef int _pid_t;
    
    
    
    
    typedef _pid_t pid_t;
    
    
    
    
    
    
    
    
    
    
    
    
    typedef unsigned short _mode_t;
    
    
    
    
    typedef _mode_t mode_t;
    
    
    
    
    
    
    
    
    
    
    
    
    typedef int _sigset_t;
    
    
    
    
    typedef _sigset_t sigset_t;
    
    
    
    
    
    
    
    
    
    
    typedef int _ssize_t;
    
    
    
    
    typedef _ssize_t ssize_t;
    
    
    
    
    
    
    
    
    
    
    typedef long long fpos64_t;
    # 151 "c:\\mingw\\include\\sys\\types.h" 3
    typedef unsigned int useconds_t;
    # 521 "c:\\mingw\\include\\stdio.h" 2 3
    extern __inline__ FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__))
     fopen64 (const char*, const char*);
    extern __inline__ FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__))
     fopen64 (const char* filename, const char* mode)
    {
      return fopen (filename, mode);
    }
    
    
    int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fseeko64 (FILE*, of
    f64_t, int);
    
    
    
    
    
    
    
    
    
    
    
    
    extern __inline__ off64_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__
    )) ftello64 (FILE *);
    extern __inline__ off64_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__
    )) ftello64 (FILE * stream)
    {
      fpos_t pos;
      if (fgetpos(stream, &pos))
        return -1LL;
      else
       return ((off64_t) pos);
    }
    # 551 "c:\\mingw\\include\\stdio.h" 3
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwprintf (FILE*, c
    onst wchar_t*, ...);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wprintf (const wch
    ar_t*, ...);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _snwprintf (wchar_
    t*, size_t, const wchar_t*, ...);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfwprintf (FILE*,
    const wchar_t*, __gnuc_va_list);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vwprintf (const wc
    har_t*, __gnuc_va_list);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vsnwprintf (wchar
    _t*, size_t, const wchar_t*, __gnuc_va_list);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vscwprintf (const
     wchar_t*, __gnuc_va_list);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwscanf (FILE*, co
    nst wchar_t*, ...);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wscanf (const wcha
    r_t*, ...);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) swscanf (const wch
    ar_t*, const wchar_t*, ...);
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetwc (FILE*);
    
    
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputwc (wchar_t
    , FILE*);
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ungetwc (wchar_
    t, FILE*);
    
    
    
    
    
    
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) swprintf (wchar_t*
    , const wchar_t*, ...);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vswprintf (wchar_t
    *, const wchar_t*, __gnuc_va_list);
    
    
    
    
     wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetws (wchar
    _t*, int, FILE*);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputws (const wcha
    r_t*, FILE*);
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getwc (FILE*);
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getwchar (void)
    ;
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putwc (wint_t,
    FILE*);
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putwchar (wint_
    t);
    
    
     void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _lock_file(FILE*)
    ;
     void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _unlock_file(FILE
    *);
     wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getws (wchar
    _t*);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _putws (const wcha
    r_t*);
     FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfdopen(int, co
    nst wchar_t *);
     FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfopen (const w
    char_t*, const wchar_t*);
     FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfreopen (const
     wchar_t*, const wchar_t*, FILE*);
     FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfsopen (const
    wchar_t*, const wchar_t*, int);
     wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtmpnam (wch
    ar_t*);
     wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtempnam (co
    nst wchar_t*, const wchar_t*);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wrename (const wc
    har_t*, const wchar_t*);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wremove (const wc
    har_t*);
     void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wperror (const w
    char_t*);
     FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wpopen (const w
    char_t*, const wchar_t*);
    
    
    
    
    
    
    int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) snwprintf (wchar_t*
     s, size_t n, const wchar_t* format, ...);
    int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsnwprintf (wchar_t
    * s, size_t n, const wchar_t* format, __gnuc_va_list arg);
    
    
    
    
    
    
    
    
    
    
    int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vwscanf (const wcha
    r_t * __restrict__, __gnuc_va_list);
    int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfwscanf (FILE * __
    restrict__,
             const wchar_t * __restrict__, __gnuc_va_list);
    int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vswscanf (const wch
    ar_t * __restrict__,
             const wchar_t * __restrict__, __gnuc_va_list);
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wpopen (const wc
    har_t*, const wchar_t*);
    
    
    
    
    
    
    
    
    
    
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fgetwchar (voi
    d);
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fputwchar (win
    t_t);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getw (FILE*);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _putw (int, FILE*)
    ;
    
    
    
    
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetwchar (void
    );
     wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputwchar (wint
    _t);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getw (FILE*);
     int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putw (int, FILE*);
    
    
    # 2 "cevre_hesapla.c" 2
    
    
    int main(int argc, char *argv[])
    {
    int yaricap;
    float cevre;
    
    
    
    
    printf(''\nYaricapi giriniz:'');
    scanf(''%d'', &yaricap);
    
    
    
    
    cevre = 2 * 3.14 * yaricap;
    printf(''Dairenin cevresi:%.2f\n'', cevre);
    
    
    return 0;
    }
    
    
    C:\C alıştırma>gcc -S cevre_hesapla.c
    cevre_hesapla.c: In function 'main':
    cevre_hesapla.c:9:8: error: empty character constant
     printf(''\nYaricapi giriniz:'');
            ^
    cevre_hesapla.c:9:1: error: stray '\' in program
     printf(''\nYaricapi giriniz:'');
     ^
    cevre_hesapla.c:9:11: error: expected ')' before 'nYaricapi'
     printf(''\nYaricapi giriniz:'');
               ^
    cevre_hesapla.c:9:29: error: empty character constant
     printf(''\nYaricapi giriniz:'');
                                 ^
    cevre_hesapla.c:10:7: error: empty character constant
     scanf(''%d'', &yaricap);
           ^
    cevre_hesapla.c:10:11: error: empty character constant
     scanf(''%d'', &yaricap);
               ^
    cevre_hesapla.c:10:10: error: 'd' undeclared (first use in this function)
     scanf(''%d'', &yaricap);
              ^
    cevre_hesapla.c:10:10: note: each undeclared identifier is reported only once fo
    r each function it appears in
    cevre_hesapla.c:10:11: error: expected ')' before '\x0'
     scanf(''%d'', &yaricap);
               ^
    cevre_hesapla.c:14:8: error: empty character constant
     printf(''Dairenin cevresi:%.2f\n'', cevre);
            ^
    cevre_hesapla.c:14:10: error: expected ')' before 'Dairenin'
     printf(''Dairenin cevresi:%.2f\n'', cevre);
              ^
    cevre_hesapla.c:14:10: error: stray '\' in program
    cevre_hesapla.c:14:33: error: empty character constant
     printf(''Dairenin cevresi:%.2f\n'', cevre);
                                     ^
    
    
    C:\C alıştırma>

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by umutefiloglu View Post
    Code:
    C:\C alıştırma>gcc -S cevre_hesapla.c
    cevre_hesapla.c: In function 'main':
    cevre_hesapla.c:9:8: error: empty character constant
    printf(''\nYaricapi giriniz:'');
    You generally need to look at the first error. Double quotes should be one character, not two.

    Also it would be helpful to start with a simpler program, e.g. one or two lines. The popular "hello world" program is recommended for this reason so you can get used to the compiler and possible error messages.

  5. #5
    Registered User
    Join Date
    May 2014
    Location
    Turkey
    Posts
    11
    Thank you a lot for your messages for help I solve problem and it was a really stupid mistake that I wrote double quotes with "shift+2" but I have to use the button which is near 1 I realized it Thank you again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. collect2: ld returned 1 exit status
    By Bryce Miller in forum C++ Programming
    Replies: 9
    Last Post: 02-28-2012, 10:28 PM
  2. collect2: ld returned 1 exit status error??
    By blindchicken11 in forum C Programming
    Replies: 11
    Last Post: 11-07-2011, 08:38 PM
  3. error: collect2: ld returned 1 exit statu
    By tommantonela in forum C++ Programming
    Replies: 5
    Last Post: 12-13-2009, 12:40 AM
  4. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  5. ERROR collect2: ld returned 1 exit status
    By meili100 in forum C++ Programming
    Replies: 13
    Last Post: 12-04-2007, 12:20 PM