exceptions without libstdc++

Mike Stump mrs@windriver.com
Mon Jun 12 15:29:00 GMT 2000


> Date: Mon, 12 Jun 2000 00:22:47 -0700
> To: gcc@gcc.gnu.org
> From: Erik Smith <ersmith@ucsd.edu>

> How do I compile a program with exceptions without linking in 
> libstdc++?   I'm trying to reduce the size of my program by excluding the 
> standard library which I'm not using.  I'm linking with the following options:

> -nodefaultlibs -lc -lgcc

> as soon as I have a throw I get the following link errors:

> bench1cpp.o(.text+0x1c): undefined reference to `__eh_alloc'
> bench1cpp.o(.text+0x31): undefined reference to `int type_info function'
> bench1cpp.o(.text+0x38): undefined reference to `__cp_push_exception'
> bench1cpp.o(.text+0x3d): undefined reference to `__throw'
> bench1cpp.o(.text+0x53): undefined reference to `__throw'
> bench1cpp.o(.text+0x61): undefined reference to `__start_cp_handler'
> bench1cpp.o(.text+0x6c): undefined reference to `__cp_pop_exception'
> bench1cpp.o(.text+0x78): undefined reference to `__throw'
> bench1cpp.o(.text+0x85): undefined reference to `__cp_pop_exception'
> bench1cpp.o(.text+0x93): undefined reference to `terminate(void)'

> which library do I need?

You're confused.  Using a library doens't make your code bigger,
unless you use it.  You cannot just remove the library on the link
line and make your code smaller.  Stop using -nodefaultlibs, it
doesn't do what you think it does.  Sorry.  This list, is the wrong
place to learn about such topics.


More information about the Gcc mailing list