From: colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters) Subject: RE: can't open -lgcc 13 Dec 1996 01:17:35 -0800 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <01BBE917.E0134720.cygnus.gnu-win32@gbird0.fu.is.saga-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Original-To: "'Ian'" Original-Cc: "'GNU-Win32'" Original-Sender: owner-gnu-win32 AT cygnus DOT com Ian[SMTP:ian AT parti DOT inforum DOT org] wrote: >Attempting to compile a hello world program under B17.1 (Win95 4.00.950) >gives a linker error "ld: cannot open -lgcc: No such file or directory". I >admit to being something of a newbie, but I can't even figure out why it's >_trying_ to find -lgcc. A quick grep of all of my header files for 'lgcc' >didn't produce anything, so why is it trying? > >Compiling hiworld.c to a .o file and then attempting "ld hiworld.o" yields: > >/d/ROOT/H-I386-C/BIN/LD.EXE: warning: cannot find entry symbol _mainCRTStartup; >defaulting to 00401000 >hiworld.o(.text+0x14):hiworld.c: undefined reference to `__main' >hiworld.o(.text+0x1e):hiworld.c: undefined reference to `printf' -lgcc is included automatically on the command line to ld by gcc. This causes ld to link the library libgcc.a into your applications (the naming convention is a UNIX-ism). This library contains functions for many calls that are generated by the compiler itself (as well as other stuff, like default_new_handler). For example, declaring an automatic array (inside a function) will call alloca, and a function called '__main' is called just before your main routine starts. The reason directly calling ld doesn't work is that you aren't including all the necessary command line arguments for ld to actually build your program. Gcc does this automatically, but if you want to do it manually you have to at least put crt0.o as the first object on the ld line and -lgcc and -lcygwin to get some other stuff. In fact there are probably other things you need, but I don't know them off the top of my head. So, the *real* error is that ld can't find libgcc.a. So, search for that file, and while you're at it, why not find all the lib*.a files included with the distribution (they should be in two or three directories at most). Then set an environment variable called LIBRARY_PATH to a list of all these directories. For example, my LIBRARY_PATH is "/usr/lib:/usr/win32/lib", but my setup is, I must tell you, quite different from your standard GNU or Cygnus setup. Good luck, Colin. PS. I think maybe in b17 you can use DOS-like paths in your environment variables, so LIBRARY_PATH could be "\usr\lib;\usr\win32\lib" (in my case) but I'm not sure, and I do know that the UNIX-style paths work. -- Colin Peters - colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp -- Saga University Dept. of Information Science -- Fundamentals of Information Science -- http://www.fu.is.saga-u.ac.jp/~colin/home.html - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".