What Happened to Object Software?

CrossGCC FAQ

Gnu CC manuals in HTML

Next Previous Contents

5. Frequently Encountered Problems

5.1 installation problem, cannot exec `cpp': No such file or directory

This error message usually appears when GCC has been installed in a place other than the one it was configured for. There are two solutions:

  • install GCC in the right place. You can find out where GCC was configured to be installed by running `gcc --print-search-dirs'. It will print something like this:
    install: /calvin/dje/rel/H-sparc-sun-solaris2/lib/gcc-lib/sparc-sun-solaris2/2.95.2/
    programs: [... omitted ...]
    libraries: [... omitted ...]
    

The `install' line tells you where GCC was configured to be installed (in this case /calvin/dje/rel/H-sparc-sun-solaris2).

  • Set the environment variable GCC_EXEC_PREFIX to the directory where you installed GCC. For example, if you installed GCC in /home/gcc (and file cc1 lives in /home/gcc/lib/gcc-lib/$target/2.95.2 where $target is the --target argument that was passed to configure), then set GCC_EXEC_PREFIX to /home/gcc/lib/gcc-lib/. The trailing `/' is important!

See the GCC info page `Environment Variables' for more information. e.g.


info -f gcc.info -n "Environment Variables"

5.2 Assembler errors while building GCC's enquire or libgcc.a

Assembler errors encountered while building enquire or libgcc.a are usually caused by GCC (the one you just built) not being able to find the right assembler. Have you installed it in a place where GCC can find it?

Were GCC and Binutils configured with the same --prefix/--exec-prefix arguments?

If the assembler hasn't been installed, the quickest solution is to create a symbolic link called `as' in the GCC build directory that points to the assembler to use.

5.3 Unresolved symbols during linking

The first thing to do is confirm you've included all the necessary libraries. When linking with the GNU linker directly, libgcc.a will not be included. libgcc.a contains various routines internal to GCC (for example software floating point support or a 32 bit integer multiply on systems without one). Add -lgcc as the last argument to GNU ld.

Note that it is not necessary to add -lgcc when linking with GCC as it will add the -lgcc automatically. To find out how GCC is invoking the linker, try to link with gcc and pass the -v option to gcc.

5.4 Where are open, read, write, close, etc. ?

The following is a typical situation people run into when linking their application.


/usr/local/m68k-coff/lib/libc.a(sbrkr.o): In function `_sbrk_r':
sbrkr.c:60: undefined reference to `sbrk'
/usr/local/m68k-coff/lib/libc.a(makebuf.o): In function `__smakebuf':
makebuf.c:93: undefined reference to `isatty'
/usr/local/m68k-coff/lib/libc.a(filer.o): In function `_open_r':
filer.c:63: undefined reference to `open'
/usr/local/m68k-coff/lib/libc.a(filer.o): In function `_close_r':
filer.c:100: undefined reference to `close'
/usr/local/m68k-coff/lib/libc.a(filer.o): In function `_lseek_r':
filer.c:142: undefined reference to `lseek'
/usr/local/m68k-coff/lib/libc.a(filer.o): In function `_read_r':
filer.c:184: undefined reference to `read'
/usr/local/m68k-coff/lib/libc.a(filer.o): In function `_write_r':
filer.c:226: undefined reference to `write'
/usr/local/m68k-coff/lib/libc.a(fstatr.o): In function `_fstat_r':
fstatr.c:61: undefined reference to `fstat'

Depending upon the target, system calls are not built into newlib's libc.a. They are too dependent upon the particular target board in use. Libgloss (which comes with newlib net releases) is intended to be the repository of such routines and may either provide them in another library that you must link against or in an object file. For systems that don't have a need for such routines, just stub them out. e.g.


int open (char *f, int flags, ...) { errno = ENOSYS; return -1; }

etc.

5.5 How do I pass options from GCC to GAS or GLD?

Sometimes one wants to have GCC pass options to the assembler or linker. This is done with the -Wa and -Wl arguments to GCC respectively. For example, suppose one wanted to pass -foo to GAS. This is done by passing -Wa,-foo to `gcc'. And for the linker, use -Wl,-foo. Multiple options may be specified either with multiple uses of -Wa or -Wl, or by separating the arguments with a comma (e.g. -Wl,-foo,-bar). If `-foo' takes an argument, use commas as in -Wa,-foo,fooarg.

5.6 How do I write an interrupt handler in C?

GCC doesn't support writing interrupt handlers (in a general way) because the FSF doesn't believe this is a useful addition to GCC. The frequency of use doesn't justify the additional complexity in GCC. Write a cover function in assembler that calls C code as necessary. Or, you could embed the necessary assembler at the top and bottom of a C function, but getting it right may be tricky, and a few bytes of ROM space will be wasted by the prologue/epilogue that are provided by GCC.

5.7 How do I write assembler code that works with m68k-aout's leading `_' and m68k-coff's lack of leading `_'?

See config/m68k/lb1sf68.asm in the GCC source tree. It uses macros that prepend (or leave off) the leading underscore as necessary (and leading `%' for registers).


Next Previous Contents