Page 1 of 1

Some wierd GCC troubles

Posted: Sat Feb 17, 2007 6:13 pm
by Fonzie
Yo all...

I have a little question concerning GCC...
I'm coding something and it appear that gcc completely lose some functions during compilation.
When pcmstop is situated in a different file, I use "extern void pcmstop(void);" and the fallowing error occurs :
C:\fonzie_dev\xgcc_code\france_five\scpu>
C:\fonzie_dev\xgcc_code\france_five\scpu>gcc -Xlinker -L C:/xgcc/6
0/ -b 68k -T Tsmcd.ld -nostdlib -o cdread. FILES -lm -lc -l135 -lg
c_index.o(.text+0x1ae):c_index.c: undefined reference to `pcmstop'
c_index.o(.text+0x208):c_index.c: undefined reference to `pcmplay'
c_index.o(.text+0x22e):c_index.c: undefined reference to `pcmstop'
I tried several things, and sometimes, if I call only one time pcmstop, there is no error... wierd, isn't it? If he find one time, he should find two times...

Any idea? It happen only in my current project...

Thx :)

Posted: Sat Feb 17, 2007 7:02 pm
by Mask of Destiny
Generally speaking if you're only going to compile a single file of a multi-file project you need to use the -c flag so that gcc only tries to compile the current file and doesn't try to link the whole project.

Posted: Sat Feb 17, 2007 7:45 pm
by Fonzie
gcc -b 68k -m68000 -O1 -c -o sega.o sega.s
gcc -b 68k -m68000 -O1 -c c_pcm.o c_pcm.c
gcc -b 68k -m68000 -O1 -c c_index.o c_index.c
gcc -b 68k -m68000 -O1 -c c_fmv.o c_fmv.c
gcc -b 68k -m68000 -O1 -c -o mcdplay.o mcdplay.S

gcc -Xlinker -L C:/xgcc/68k/2_8_1/m68000/ -b 68k -T Tsmcd.ld -nostdlib -o cdread0. FILES -lm -lc -l135 -lgcc -lg
68k-objc -O binary cdread0. cdread.bin
Here is the compile.bat... Really, i don't understand what is wrong... Maybe a cluster of my HD that got wrong?
I mean, every project i do use the same layout... and only this one cause problem... It seems i use buggy variable/function names...

Posted: Sat Feb 17, 2007 8:00 pm
by Fonzie
Ok, I think I got it :)
It is my fault, but still a gcc bug ;) haha :P
In fact, if you have a same variable name defined into two files, gcc can get glitchy... My variable was pcm_bank... and each function that had "pcm" in their name were going fuzzy :)

I may delete the whole topic... :)

Thx MOD anyway :)

Posted: Fri Feb 23, 2007 4:48 pm
by fdarkangel
May I ask the output of gcc -v?

Posted: Fri Feb 23, 2007 9:25 pm
by Mask of Destiny
2.8.1 from the looks of it.

You really should consider upgrading to a more recent version. At the very least you should be using one of the 2.9.X version if not one of the 3.X or 4.X versions.