This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc linking problem - badly installed?


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@cygnus.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]