gcc linking problem - badly installed?

Eric Moyer ii0@juno.com
Thu Aug 16 06:32:00 GMT 2001


First, a restatement of your problem:

ld and gcc fail at linking .o files.
Particularly for hello world.

------ 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/



More information about the Cygwin mailing list