Some wierd GCC troubles

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Some wierd GCC troubles

Post by Fonzie » Sat Feb 17, 2007 6:13 pm

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 :)

Mask of Destiny
Very interested
Posts: 616
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Sat Feb 17, 2007 7:02 pm

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.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Sat Feb 17, 2007 7:45 pm

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...

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Sat Feb 17, 2007 8:00 pm

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 :)

fdarkangel
Interested
Posts: 24
Joined: Sun Dec 17, 2006 8:28 pm
Location: Osaka, Japan

Post by fdarkangel » Fri Feb 23, 2007 4:48 pm

May I ask the output of gcc -v?

Mask of Destiny
Very interested
Posts: 616
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Fri Feb 23, 2007 9:25 pm

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.

Post Reply