Time pass by

Sunshine and rain of a developer

Posts Tagged ‘gdb’

GDB with Multiple Source Code Program

Posted by vanguard33 on December 7, 2008

If you try to debug a multiple files program with gdb, someting you see error output from gdb like this

….

/usr/src/build/87732-i386/BUILD/gcc-2.96-20000731/obj-i386-redhat-linux/gcc/../../gcc/libgcc2.c(.rodata+0×0):

multiple definition of `_fp_hw’

/usr/local/condor/lib/condor_rt0.o(.rodata+0×0): first defined here

hello.remote: In function `__moddi3′:

/usr/src/build/87732-i386/BUILD/gcc-2.96-20000731/obj-i386-redhat-linux/gcc/../../gcc/libgcc2.c(.data+0×4):

multiple definition of `__dso_handle’

/usr/lib/gcc-lib/i386-redhat-linux/2.96/crtbegin.o(.data+0×0): first

defined here

hello.remote: In function `_init’:

hello.remote(.init+0×0): multiple definition of `_init’

……

add --allow-multiple-definition to your compile flags. This tells the linker allow 
multiple definition of _init or other fucntions

Now you can use gdb to debug.

Posted in C | Tagged: | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.