🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
8 messages
8 total messages Started by Jesse Rivera Wed, 03 Dec 1997 00:00
compiling problem.
#23953
Author: Jesse Rivera
Date: Wed, 03 Dec 1997 00:00
19 lines
961 bytes
I'm not sure if this is a unix, news, or gcc problem but hopefully
someone has seen this:

Building subst...
cc -o subst subst.c
collect2: cannot find `ld'
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `c'

I can't seem to get past this.  What is 'ld' and 'collect2'?  Any
assistance would be greatly appreciated.

-Jesse



Re: compiling problem.
#24018
Author: Ron Echeverri
Date: Thu, 04 Dec 1997 00:00
28 lines
1567 bytes
In article <34861B45.4ACB8384@inow.com>,
Jesse Rivera  <jrivera@riscorian.com> wrote:
>I'm not sure if this is a unix, news, or gcc problem but hopefully
>someone has seen this:

>Building subst...
>cc -o subst subst.c
>collect2: cannot find `ld'
>collect2: ld returned 1 exit status
>*** Error code 1
>make: Fatal error: Command failed for target `c'

>I can't seem to get past this.  What is 'ld' and 'collect2'?  Any
>assistance would be greatly appreciated.

This is clearly not a unix, news, or gcc problem, but a compiler
problem.  Meaning, the guy who's compiling the software needs to find
someone who actually knows what he's doing.

rone
-- 
Ron Echeverri	<rone+sig@best.net>	| "Who is the boss of you?  Me!  I am
Systems/Usenet Administration		|  the boss of you!  I am the boss of
Best Internet Communications, Inc.	|  you!  I am the boss of you!"
<URL:http://www.ennui.org/~rone/>	|		- The Grand Inquisitor

Re: compiling problem.
#24019
Author: Tural KAPTAN
Date: Thu, 04 Dec 1997 00:00
29 lines
1266 bytes
Jesse Rivera wrote:
> 
> I'm not sure if this is a unix, news, or gcc problem but hopefully
> someone has seen this:
> 
> Building subst...
> cc -o subst subst.c
> collect2: cannot find `ld'

This is gcc error, Your compiler (gcc) cannot find ld( link editor for
object files). Check where is the file, and include the PATH ..

Hope this help, 

Tural KAPTAN
Ulak-NET


> collect2: ld returned 1 exit status
> *** Error code 1
> make: Fatal error: Command failed for target `c'
> 
> I can't seem to get past this.  What is 'ld' and 'collect2'?  Any
> assistance would be greatly appreciated.
> 
> -Jesse

Re: compiling problem.
#24044
Author: Matt Casters
Date: Fri, 05 Dec 1997 00:00
52 lines
2030 bytes
Jesse Rivera wrote:
> 
> I'm not sure if this is a unix, news, or gcc problem but hopefully
> someone has seen this:
> 
> Building subst...
> cc -o subst subst.c
> collect2: cannot find `ld'
> collect2: ld returned 1 exit status
> *** Error code 1
> make: Fatal error: Command failed for target `c'
> 
> I can't seem to get past this.  What is 'ld' and 'collect2'?  Any
> assistance would be greatly appreciated.
> 
> -Jesse

Type which ld
If ld can not be found, you should include ld in your path.  Since it's
gcc you're talking about it should reside somewhere in /usr/local/
(find /usr/local -name ld -print)

$ man ld

ld Command

Purpose

Links object files.

Description

The ld command, also called the linkage editor or binder, combines
object files, archives, and import files into one output object file,
resolving external references. It produces an executable object file
that can be run. In addition, if you specify the ld command without
the -s flag, you can use the output file as an InputFile parameter
in another call to the ld command. By default, the ld command creates
and places its output in the a.out file.



HTH,

-- 
Matt Casters <matt.casters@volvo.be>     MemodID: VEDA.TN91217
Unix System Administrator
Volvo Data Belgium, Eksaarderijweg 188, 9041 Oostakker
Tel: +32-9/255.60.76 (temp.)   FAX: +32-9/255.60.83

Re: compiling problem.
#24146
Author: Kai Ruottu
Date: Mon, 08 Dec 1997 00:00
248 lines
12006 bytes
On 4 Dec 1997 10:34:02 -0800, Ron Echeverri
<rone+usenet@bofh.noc.best.net> wrote:

>In article <34861B45.4ACB8384@inow.com>,
>Jesse Rivera  <jrivera@riscorian.com> wrote:
>>I'm not sure if this is a unix, news, or gcc problem but hopefully
>>someone has seen this:
>
>>Building subst...
>>cc -o subst subst.c
>>collect2: cannot find `ld'
>>collect2: ld returned 1 exit status
>>*** Error code 1
>>make: Fatal error: Command failed for target `c'
>
>>I can't seem to get past this.  What is 'ld' and 'collect2'?  Any
>>assistance would be greatly appreciated.
>
>This is clearly not a unix, news, or gcc problem, but a compiler
>problem.  Meaning, the guy who's compiling the software needs to find
>someone who actually knows what he's doing.

 I think this is a educational problem. I have met a lot of students
who have passed their C course without knowing afterwards why they put
the '#inlude' rows into a program and what the hell happens during the
compile process...

 Looking e.g. the Borland C/C++ bin-directory we'll find 'cpp.exe',
'brcc.exe' and 'tlink.exe' which seem to be the compiler passes. But
the compiler passes aren't handled during a C course -- It doesn't
seem to matter at all how the compiler works, just only how to use
its IDE controls...

 When learning to drive a car, it normally doesn't matter how the car
works, but when it doesn't work any more, one must be able to check if
there aren't any gasoline or the accumulator is empty... So, one must
know a little how a car works. A compiler user must know a little how
a compiler works in order to solve the possible simple problems...

 Perhaps this is a 'when everybody already knows this, why put it
here' - like syndrom the gcc manual writers have... It's possible that
an author writing about Borland or MS compilers doesn't know the
compile process him/herself, so don't expect to find a compile process
chart from those "Teach Yourself C in 1 hour" - like books...but I
expect a gcc manual writer to know this and also to tell it to the
readers...

 When we look at the GCC based compilers from some commercial
providers, e.g. from Motorola, we'll surely find a figure about the
compile & develope process in the first pages of the User's Manual.
(Look e.g. at the DSP563CCC User's Manual). These writers know how
stupid and ignorant the reader can be...

 But when we look at the "Using and Porting GNU CC" from RMS, or "The
Linux Programmer's Guide", there aren't any chart or figure about the
compile process. I don't remember DJGPP docs have anything about this,
neither emx nor cygwin32 docs...

 So, where all these poor askers will find info about why and where
'cpp', 'cc1', 'as', 'ld' etc will be needed? The only way seems to be
to ask someone who knows, but I'm really tired to see these simple
questions in all the news groups...

 Let's send mail to RMS, DJ, Eberhard & Co. and ask them to put a
chart about the compile process into their 'User's Manual's every time
we see these "cannot find cpp, what is cpp anyway?" - like questions.
I have seen hundred or so of these only in the cygwin32 mailing list.

 And let's ask them to teach to use the 'gcc -print-search-dirs',
'gcc -v' etc. commands to solve problems after just installing gcc...
An example about "How to compile the famous 'hello_world.c'" would
also be nice because a lot seem not to know how to compile with gcc...

 Here's a prototype, a sample from the "Embed with the GNU Development
Tools" that I'm preparing, borrowing stuff from the Cygnus "Embed with
GNU" docs and using my non-native bad English... (This will be
available as a texinfo src and converted to dvi, ps and WinHelp
documents, if I find a ftp-site to hold it...). Perhaps if I had
written this using english, not bad English, this weren't so bad...;-)
The good thing is that I mustn't speak, otherwise it would happen just
like it happened to one of our previous foreigng ministers, whose
words were written in paper as: "I hope that we should live in peace",
but he spoke "I hope that we should leave in piss"...

---------------
Introduction

The free GNU C/C++ compiler, gcc is not anyhow different from a normal
commercial C/C++ compiler working under UNIX or DOS.  What makes the
difference nowadays, is the lack of a common IDE, (Integrated
Development Environment) for the common GUI's like Windows and X
Window, where to edit programs and from where to use all the compiler
tools. Instead of an IDE, GCC uses still the 'old method' and is
normally used from the command line. Furthermore, the building of a
project, which consists from many source files and dependencies
between them, is organized with using makefiles and the make utility
to handle them.

That said, there are some IDE's available, however. One of these is
Fred Kruse's xwpe X Window Programming Environment, which can be
compiled as a Borland like IDE for DOS/DJGPP or UNIX (using the ANSI
etc. terminal controls), or as a X Window application.  Another well
known IDE is RHIDE, which works only with DJGPP. But there is no
approved standard for the GCC-IDE yet.

Most of the current commercial C/C++ compilers can also be used from
the command line and have the make utility, but it is more common to
use the included IDE interface, when teaching C/C++ for beginners.
So, the lack of a standard IDE for GCC seems to be a big problem for
those used to work under MS Windows, Macintosh or OS/2.  However, for
the old C/C++ veterans there is nothing weird in using GCC from the
command line.

The next sections will describe the GNU C/C++ compiler structure, its
options, and the environment variables that can be used to control its
functionality. Furthermore the GNU assembler, as, the GNU linker, ld,
and the GNU debugger, gdb, will be handled too.  We will use the name
GNU development tools to mean these all.  Although the options for the
various GNU development tools are covered in more detail elsewhere,
the amount of options can be an overwhelming amount of stuff, so the
options most suited to embedded systems are summarized here in this
document.

Tool names	How to call the tools.
Invoking GCC	Using GCC and its common options.
GCC structure	What programs are needed for a compile.

<clipping tool names>

Invoking GNU C/C++

GCC by itself only compiles the C or C++ code into assembler.
Typically GCC invokes all the passes required for you. The following
figure shows the developing process.


Figure 1.  Developing with GNU C/C++

If we would want to compile the following C language "Hello world"
program, saved as the file hello.c : 

#include <stdio.h>

int
main (void)
{
    printf("Hello World\n");
    return 0;
}

and make an executable program, as the file hello, this could be done
using the following command line: 

gcc -o hello hello.c

The user could take the command gcc as the GNU C/C++ compiler, but it
is only the compiler driver, which starts all the programs needed for
the compiling as subprocesses and gives them all the needed options
and filenames.

The previous example is only a simply case, and in real work it is not
common to compile a program just in one big slump into an executable.
Normally it is divided into separately compiled source modules, which
after compiling will be linked together (with the already compiled
library objects in the C Standard Library and other libraries) to form
the final executable.

The structure of GNU C/C++

As we saw in the Figure 1, the GNU C/C++ compiler consists of three
programs: 

� The compiler driver, gcc, is a program that parses and interprets
the command line, and then calls each of the other needed programs in
sequence, depending on its input programs and the command line
options. The usual gcc command line will cause ld to link in the
startup code and additional libraries by default.

� The macro preprocessor, cpp, is the C preprocessor. Its input is a
program file optionally containing preprocessing commands.  It will
merge in the include files, expand all macros definitions, and process
all the #ifdef sections. To see the output of ccp, invoke gcc with the
-E option, and the preprocessed file will be printed on the stdout.

� The C or C++ language processor, cc1 or cc1plus, parses and
optimizes its input C or C++ program, and generates an machine
specific assembly (symbolic machine code) program.  

The program's output must be assembled by the GNU Assembler, as, to
produce an object code program.  as is automatically called by the gcc
driver (unless you use the -S option).

GNU assembler started it's life to only function as a compiler pass,
but these days it can also be used as a source level assembler. When
used as a source level assembler, it has a companion assembler
preprocessor called gasp. This has a syntax similar to most other
assembler macros packages. gas emits a relocatable object file from
the assembler source. The object file contains the executable part of
the application, and debug symbols.

You produce an executable program by using the GNU linker, ld, to link
one or more object files and, optionally, run-time libraries. ld is
also automatically called by the gcc driver (unless you use the -c
option).

ld is responsible for resolving the addresses and symbols to something
that will be fully self-contained. Some RTOS's use relocatable object
file formats like a.out, coff or elf but more commonly the final image
will only use absolute addresses for symbols. This enables code to be
burned into PROMS as well.

Although ld can produce an executable image, there is usually a hidden
object file named crt0.o that is required as startup code.  With this
startup code and a memory map, the executable image will actually run
on the target environment. The startup code usually defines a special
symbol like _start that is the default base address for the
application, and the first symbol in the executable image.  See
Porting libgloss.

If you plan to use any routines from the Standard C library, you'll
also need to implement the functions that this library is dependent
on. See Porting newlib.

The executable image can be loaded into the target system through a
serial communications line or sometimes even using ftp (with TCP/IP)
on a LAN. Or the program can be converted into a Intel hex file and
burned into a EPROM, which will then put into the target system, or it
must also be converted into a Intel hex or Motorola srec or some other
format before loading into the target system. One of the GNU binutils
programs, objcopy, is aimed at these conversion tasks. See What to do
now.

Debugging the program is possible with GDB (configured as a remote
debugger) talking with the target system through a serial
communications line or even using telnet on a LAN. See Porting GDB.

Many targets can have also a simulator program, run, available.  This
can execute the compiled and linked program on the host system and
tries to simulate the target processor and the target system as well
as possible. A connection with GDB is possible with the gdb command
target sim. So, a lot of debugging can perhaps be done without needing
the target system.

-----------


Re: compiling problem.
#24171
Author: Ron Echeverri
Date: Tue, 09 Dec 1997 00:00
17 lines
1291 bytes
In article <Pine.LNX.3.93.971209112850.17276D-100000@vader.inow.com>,
Jesus Rivera  <rivera@inow.com> wrote:
>I've never taken a C class and am attemting to learn on my own.  Is that
>not what news is all about?

No, news is about posting a followup, or emailing a reply, but not
both.

rone
-- 
Ron Echeverri	<rone+sig@best.net>	| "Who is the boss of you?  Me!  I am
Systems/Usenet Administration		|  the boss of you!  I am the boss of
Best Internet Communications, Inc.	|  you!  I am the boss of you!"
<URL:http://www.ennui.org/~rone/>	|		- The Grand Inquisitor

Re: compiling problem.
#24187
Author: Jesus Rivera
Date: Tue, 09 Dec 1997 00:00
62 lines
2897 bytes
This is a response to my "idiotic question".  Mea culpa

However I did not mean for this to turn into a political discussion.  to
those of you who were kind enough to offer their assistance I thank you.
Your help is very much appreciated.

To those of you who had nothing better to do than attack the question,
regarding it as 'stupid' or '..tired of these questions.' I pity you.
For it seems that because of your troubled childhood you can only prove
your superiority by attacking others who may not be as up to speed on a
topic than you may be.  

I've never taken a C class and am attemting to learn on my own.  Is that
not what news is all about?  Is there not something known as news
ettiquette or what of the golden rule?  As those of you have said, "...I'm
tired of these questions."  I also grow tired of morons who need to
comment on everything they see, and given the opportunity attack those of
us who are only attempting to better ourselves.

Regards,

-Jesse


-------------------------------------------------
Jesse Rivera
rivera@inow.com
-------------------------------------------------

On 4 Dec 1997, Ron Echeverri wrote:

> In article <34861B45.4ACB8384@inow.com>,
> Jesse Rivera  <jrivera@riscorian.com> wrote:
> >I'm not sure if this is a unix, news, or gcc problem but hopefully
> >someone has seen this:
> 
> >Building subst...
> >cc -o subst subst.c
> >collect2: cannot find `ld'
> >collect2: ld returned 1 exit status
> >*** Error code 1
> >make: Fatal error: Command failed for target `c'
> 
> >I can't seem to get past this.  What is 'ld' and 'collect2'?  Any
> >assistance would be greatly appreciated.
> 
> This is clearly not a unix, news, or gcc problem, but a compiler
> problem.  Meaning, the guy who's compiling the software needs to find
> someone who actually knows what he's doing.
> 
> rone
> -- 
> Ron Echeverri	<rone+sig@best.net>	| "Who is the boss of you?  Me!  I am
> Systems/Usenet Administration		|  the boss of you!  I am the boss of
> Best Internet Communications, Inc.	|  you!  I am the boss of you!"
> <URL:http://www.ennui.org/~rone/>	|		- The Grand Inquisitor
> 
> 


Re: compiling problem.
#24221
Author: Reinier Post
Date: Wed, 10 Dec 1997 00:00
15 lines
1057 bytes
Jesus Rivera <rivera@inow.com> wrote:

[...]

>For it seems that because of your troubled childhood you can only prove
>your superiority by attacking others who may not be as up to speed on a
>topic than you may be.  

... or who post to the wrong newsgroup (comp.unix.admin)

-- 
Reinier

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads