delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/08/16/09:40:33

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Thu, 16 Aug 2001 09:40:02 -0400
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: gcc linking problem - badly installed?
Message-ID: <20010816094002.D27562@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20010816 DOT 093004 DOT -3754375 DOT 0 DOT ii0 AT juno DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <20010816.093004.-3754375.0.ii0@juno.com>; from ii0@juno.com on Thu, Aug 16, 2001 at 09:29:56AM -0400

On Thu, Aug 16, 2001 at 09:29:56AM -0400, Eric Moyer wrote:
>First, a restatement of your problem:
>
>ld and gcc fail at linking .o files.
>Particularly for hello world.

There is a very simple answer to this question: Don't use 'ld' to link
your files.

So, either:

    gcc -o test_c.exe test_c.c

or

    gcc -c test_c.c
    gcc -o test_c.exe test_c.o

cgf

>------ Excerpt from log -------
>+ gcc test_c.o
>/PROGS/CYGWIN/USR/BIN/ld: cannot open crt0.o: No such file or directory
>collect2: ld returned 1 exit status
>+ gcc -c test_c.c
>+ ld test_c.o
>ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to
>00401000
>test_c.o(.text+0x1b):test_c.c: undefined reference to `__main'
>test_c.o(.text+0x2d):test_c.c: undefined reference to `printf'
>
>------ End excerpt from log -------
>
>
>**** Potential solution Part 1:
>I had a similar problem last week with the linker because I did not have
>the right libraries installed.  The minimum packages needed to run GCC
>(and g77) are:
>
> 2646 binutils
>  775 cygwin
> 3455 gcc
>  626 w32api
>
>For an extra meg, download:
>   34 ash
>  564 bash
>  406 fileutils
>  236 make
>
>(the numbers are the compressed file sizes)
>
>(Re)installing these packages into the same base cygwin directory will
>ensure that you have the correct files in /lib
>
>**** Potential Solution Part 2:
>But this may not solve your problem completely.  Though I have been
>successfully compiling and running programs for a week now.  ld also
>fails on my machine when executed as you specify.  gcc also gives similar
>errors when executed.  Part of your problem is that you are calling the
>linker without including the necessary system startup files.
>
>The following invocation of ld works for me:
>$ ld -o test_c.exe /lib/crt0.o test_c.o -lc -lkernel32
>
>
>--Eric
>
>--
>Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>Bug reporting:         http://cygwin.com/bugs.html
>Documentation:         http://cygwin.com/docs.html
>FAQ:                   http://cygwin.com/faq/

-- 
cgf AT cygnus DOT com                        Red Hat, Inc.
http://sources.redhat.com/            http://www.redhat.com/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019