Skip to main content
ezanen9
Associate III
Aug 26, 2005 3:19 AM UTC
Question

GNU compiler

Posted on August 26, 2005 at 05:19

GNU compiler

This topic has been closed for replies.

22 replies

ezanen9
ezanen9Author
Associate III
Aug 23, 2005 4:40 AM UTC
Posted on August 23, 2005 at 06:40

Hi, I am working with the Hitop5 IDE and a HITEX evaluation board. HITOP5 works with a supplied GNU compiler(v3.3.2).

My problem is the following: when I am using the devide sign '' / '' (in the C langue), I recieve a error while compiling my C-langue program. The compile error is:

source/main.c:76: undefined reference to `__divsi3'

I think I found a possible problem. The problem is in the libgcc.a low-level runtime library. The library is not getting properly linked with the project or it is an incorrect version(Am I right here?).

I have tried the multiply sign '' * '' and this works just fine! I tried to solve this problem myself and it kept my busy for two days now. I don't get the problem fixed :(

The version of the GNU compiler is 3.3.2.

Can someoney help me solving this problem. It is driving me nuts!

thanks,

Jimmey

ben2
Associate III
Aug 23, 2005 4:54 AM UTC
Posted on August 23, 2005 at 06:54

I think I had similar problems - am using eclipse and gcc 3.4.2.

you need to make sure the path to the library is correct - libgcc.a on my setup is installed in a different directory.

Also can you see just what exactly is being passed on the command line when the compiler is invoked ?

peppecaselli
Associate II
Aug 23, 2005 5:22 AM UTC
Posted on August 23, 2005 at 07:22

Hi!,

I do not know well micro that he uses. Perhaps if you write the makefile you must change the option ''-nostdlib'' with

''-nostartfiles''.

ben2
Associate III
Aug 23, 2005 5:31 AM UTC
Posted on August 23, 2005 at 07:31

I have just upgraded to version 3.4.3 of the arm tools from gnuarm.org and have no problems. I suspect it is a path issue.

in my makefile I have the following

CFLAGS = -c -O2 -Wall -g -mcpu=arm7tdmi -mlittle-endian -ffunction-sections

LIB_PATH = -L F:/gnu-arm/GNUARM/arm-elf/lib -L f:/gnu-arm/GNUARM/lib/gcc/arm-elf/3.4.3

build_for_flash: $(SOURCE)

$(LD) -o flash.elf $(SOURCE) $(USB_INTERFACE) $(LIBS) $(LIB_PATH) -lc -lgcc -lm -lg -T ./flash.ln --gc-section

this is including libgcc.a

ezanen9
ezanen9Author
Associate III
Aug 23, 2005 5:36 AM UTC
Posted on August 23, 2005 at 07:36

The problem is that I don't know the GNU/GCC compiler very well. I know that the problem is in the library but I don't know were to change the path to it.

Is it paerhaps wise to de-install my 3.3.2 version and upgrade to a higher version?

Thanks,

ben2
Associate III
Aug 23, 2005 5:40 AM UTC
Posted on August 23, 2005 at 07:40

It is most likely a setting in your IDE. I doubt there is a problem with the version of gcc you are using.

I am not familiar with the IDE though. I suggest you look for some form of project/library/path settings.

Is it running an external makefile ?

do you get any for of output from the build process ?

ezanen9
ezanen9Author
Associate III
Aug 23, 2005 6:16 AM UTC
Posted on August 23, 2005 at 08:16

Yes I have some setting:project>settings>Compiler toolchain>Tool settings>

Here I can set the default options for Assembler/compiler and the linker. The linker option now say: --cref -t -static -lc -lm --start-group

I don't know what it means. In my project directoy there is a make file but I don't know if it's being used. I deleted the make file and I could still build/rebuild my program even after restarting the IDE.

There are some path options in a .LD file also in the project folder, but I don't know if these are the right options.

The output of the build proces says:

=== Build log ===

arm-elf-gcc.exe -c -gdwarf-2 -MD -mapcs-frame -O0 -mcpu=arm7tdmi -w -mthumb-interwork -I.\source\ -o .\objects\interrupt.o ..\..\..\Software\source\interrupt.c

arm-elf-gcc.exe -c -gdwarf-2 -MD -mapcs-frame -O0 -mcpu=arm7tdmi -w -mthumb-interwork -I.\source\ -o .\objects\main.o .\source\main.c

arm-elf-as.exe -m armv4t -gdwarf2 -mthumb-interwork -o .\objects\startup.o ..\..\..\Software\source\startup.s

arm-elf-ld.exe --cref -t -static -lc -lm -Map=Example.map -o .\objects\Example.elf -T.\objects\Example.ld

objects\main.o(.text+0x6c): In function `ADC_IRQ_isr':

source/main.c:76: undefined reference to `__divsi3'

arm-elf-ld: link errors found, deleting executable `.\objects\Example.elf'

arm-elf-ld: mode armelf

objects\startup.o

objects\main.o

objects\interrupt.o

ben2
Associate III
Aug 23, 2005 6:22 AM UTC
Posted on August 23, 2005 at 08:22

it looks like it is not including libgcc.a

you need a -lgcc on the linker option

ezanen9
ezanen9Author
Associate III
Aug 23, 2005 7:14 AM UTC
Posted on August 23, 2005 at 09:14

I tried that but I don't know if I used the right syntax to include the libgcc.a library.

I put : --cref -t -static -lc -lgcc -lm --start-group in the linker option box. Is this right?

Still having the same error

The buid report says:

=== Build log ===

arm-elf-gcc.exe -c -gdwarf-2 -MD -mapcs-frame -O0 -mcpu=arm7tdmi -w -mthumb-interwork -I.\source\ -o .\objects\interrupt.o ..\..\..\Software\source\interrupt.c

arm-elf-gcc.exe -c -gdwarf-2 -MD -mapcs-frame -O0 -mcpu=arm7tdmi -w -mthumb-interwork -I.\source\ -o .\objects\main.o .\source\main.c

arm-elf-as.exe -m armv4t -gdwarf2 -mthumb-interwork -o .\objects\startup.o ..\..\..\Software\source\startup.s

arm-elf-ld.exe --cref -t -static -lc -lm -Map=Example.map -o .\objects\Example.elf -T.\objects\Example.ld

objects\main.o(.text+0x6c): In function `ADC_IRQ_isr':

source/main.c:76: undefined reference to `__divsi3'

arm-elf-ld: link errors found, deleting executable `.\objects\Example.elf'

arm-elf-ld: mode armelf

objects\startup.o

objects\main.o

objects\interrupt.o

Here you can see that the linker still uses arm --cref -t -static -lc -lm -Map without the lgcc library I added in the option box.

By the way, how does the linker know the path of the libgcc.a library?

ben2
Associate III
Aug 23, 2005 9:24 AM UTC
Posted on August 23, 2005 at 11:24

the options being passed to the linker set the path. arm-elf-ld probably has a default search path or according the the man page a link script.

the -L sets a path to look for libraries. you can have more than 1. e.g -Lc:/gnuarm/lib

the -l (small L) tells the linker which libraries you want to include. For libraries you dont specifiy the ''lib'' or ''.a'' part, so to use libgcc.a you use -lgcc.

What is the contents of the Example.ld file ? this may list additional paths or libraries.

Looking at the output of the linker it would appear to not be using the options you have added. I dont know why that is, unless it is picking the options for someplace else.