linking error undefined symbol _start

linking error undefined symbol _start

Post by Alex Tyrrel » Wed, 03 Jul 2002 06:38:42

I'm brand new at linux development, I'm currently having problems with
linker specifically that it creates the output file but issues a warning
that it couldn't find symbol _start ( I'm working with a very basic "hello
world" app).  Then I can't even run the resulting executable, oddly enough
the shell says the file doesn't exist.  I think this is a common problem and
I'm most interested in how it relates to ctr0.o because the ld man page
mentions it and I don't have one anywhere on my system red hat 7.1 kernel
2.4.18 smp.  Instead I have /usr/lib/crt1.o ../crtn.o crti.o.  I'm using gcc
3.0.4 and gnu ld 2.10.91.

As a quick rundown I do this-

gcc main.c -c -o main.o
ld -o main main.o -lc
warning: unresolved symbol _start

Incidentally if I try linking with /usr/lib/crt1.o,crti.i,crtn.o the warning
goes away but the exe still won't run correctly.



linking error undefined symbol _start

Post by Stephane SOPPER » Wed, 03 Jul 2002 03:49:19

Quote:> gcc main.c -c -o main.o
> ld -o main main.o -lc
> warning: unresolved symbol _start

Actually you never runs ld directly:
you can do:
gcc -o main main.c
or in two steps:
gcc -c main.c (that will create main.o)
gcc -o main main.o (that will link the program)

for C++ replace gcc by g++

Stephane SOPPERA


linking error undefined symbol _start

Post by Eric P. McC » Wed, 03 Jul 2002 04:08:49

> ld -o main main.o -lc

Don't link with `ld', use `cc' or `c++' (whichever is appropriate).


"Last I checked, it wasn't the power cord for the Clue Generator that
was sticking up your ass." - John Novak, rasfwrj


linking error undefined symbol _start

Post by Floyd Davidso » Wed, 03 Jul 2002 04:47:19

>> gcc main.c -c -o main.o
>> ld -o main main.o -lc
>> warning: unresolved symbol _start

>Actually you never runs ld directly:
>you can do:
>gcc -o main main.c
>or in two steps:
>gcc -c main.c (that will create main.o)
>gcc -o main main.o (that will link the program)

>for C++ replace gcc by g++

To make this interesting, in order to learn what ld does, try

  gcc -v -o main main.c

The linker called won't be ld, but to manually link a program
ld can be used with the identical command line.

Floyd L. Davidson         <>


1. undefined symbol when linking bash

I'm trying to make bash 1.12 on an AT&T 3B2/400
running System V 3.2.2.  After a little tinkering
around, all the libraries and object files are done.
However, when it comes to link time, the make dies
with ....

        cc     -g -L./lib/readline/  -L./lib/glob/ \
           -o bash shell.o general.o make_cmd.o print_cmd.o   dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o  expr.o flags.o jobs.o subst.o hash.o mailcheck.o test.o  trap.o alias.o ./lib/malloc/malloc.o  braces.o unwind_prot.o  siglist.o  version.o bashline.o builtins/libbuiltins.a -lreadline -ltermcap -lglob -lPW
undefined                       first referenced
 symbol                             in file
opendir                             ./lib/readline//libreadline.a
readdir                             ./lib/readline//libreadline.a
closedir                            ./lib/readline//libreadline.a
ld fatal: Symbol referencing errors. No output written to bash
*** Error code 13
`all' not remade because of errors

Earlier, the readline library wouldn't make until I snarfed a
sys/ndir.h file from another box (SCO).  (It was dying with references
to syntax errors on lines 5172 and 5257 of readline.c)  In case
it helps, here are those 2 lines:

  5172: static DIR *directory;

  5255:  {
  5256:  closedir (directory);
  5257:  directory = (DIR *)NULL;
  5258:  }

The 3 functions readdir, opendir, and closedir seem to have been
defined in the ndir.h file.  I also had to pull in sys/dirent.h
from another box, as the dirent.h on the AT&T box didn't have
DIR defined.  

Anyone know a way around these obstacles?

Randall W. Hron
Roswell, GA  USA

2. ODBC drivers for linux

3. Dynamic linking using dlopen(): undefined symbols

4. What's the secret?

5. numerous undefined symbols while linking kernel

6. Java Swing

7. Undefined Symbol XSolarisIASetProcessInfo When Linking

8. Unable to create shared library

9. Dynamic Link library and undefined symbols?

10. Undefined symbols with Forte link : std::basic_ostream/std::string etc...

11. undefined symbol itoa when linking shared library to -lm and -lc

12. Undefined symbols after static link

13. Problems linking gcc/sun : Undefined Symbol