Thread: a problem with cygwin

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    51

    Question a problem with cygwin

    Hi,
    Ive just installed cygwin on my comp so that i can compile my C programs with it. Heres the problem im getting:

    my test code:

    Code:
    #include <stdio.h>
    
    
    main()
    
    {
    printf("SOMETHING.\n");
    }
    heres the error cygwin gives me:

    $ gcc -o test test.c
    test.c:6:5: warning: no newline at end of file
    /usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../../i686-pc-cygwin/bin/ld: cannot fi
    nd -luser32
    collect2: ld returned 1 exit status


    Can anyone help? btw if you hadnt noticed im very new to C.. lol.

    Thanks

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    Why do you guys do 'main'? Its 'int main()'. Seriously, what book teaches you that?

    Add a 'return 0; at the end of the function.

    Code:
    #include <stdio.h>
    
    int main() {
        printf("SOMETHING.\n"); 
    
        return 0;
    }

  3. #3
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    I believe GCC makes you push enter at the end of your code. Insert a blank line after your last bracket.
    Away.

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    51
    ok i changed the code to what you said, and im getting this back:

    $ gcc -o test test.c
    /usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../../i686-pc-cygwin/bin/ld: cannot fi
    nd -luser32
    collect2: ld returned 1 exit status


    any ideas on why and what i need to do to fix it?

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    dam those cryptic error messages.

  6. #6
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    that is a linker error, do you have the win32 equivlent of glib? it is compiling fine, just not linking.

  7. #7
    Registered User
    Join Date
    Aug 2002
    Posts
    51
    all i have done is download cygwin and install it... i really dont know what i have got and what i havent... how do i find out? Sorry im really dumb. lol

  8. #8
    Registered User
    Join Date
    Jul 2003
    Posts
    61
    When you were installing cygwin, did select all the packages in the Development (or whatever it's called) group?
    $ENV: FreeBSD, gcc, emacs

  9. #9
    Registered User
    Join Date
    Aug 2002
    Posts
    51
    youll all be happy to know i got it working... thanks all for help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Problems with compiling code in cygwin
    By firyace in forum C++ Programming
    Replies: 4
    Last Post: 06-01-2007, 08:16 AM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. path problem in cygwin
    By elliptic in forum Tech Board
    Replies: 1
    Last Post: 06-18-2006, 09:10 PM