Topic: Using Extern Problem

Hi,
I created two C files in latest version of Ride 7 namely Main.c and Serial.c. The content of Main.C is as follows.

//////////////////////////////// Main.c /////////////////////////////////////////
extern void Serial_Comm_C(void);

unsigned char card_counter=0;



int main(void)
{   
   
    while(1)
    {           
        Serial_Comm_C();          
    }
}
//////////////////////////////////////////////////////////////////////////////

Whereas the content of Serial.C is as follows.

///////////////////////////// Serial.C /////////////////////////////////////////
extern unsigned char card_counter;

void Next_Card(void)
{
    card_counter++;
    switch(card_counter)
    {
        case  4:
        {
            card_counter=10;
            break;
        }
        case  14:
        {
            card_counter=20;
            break;
        }               
    }   
}

void Serial_Comm_C(void)
{   
    Next_Card();           
}
/////////////////////////////////////////////////////////////////////////////////

When I try to build my project, I get following error. Can anyone please tell me if there are some updates required in project setting.

///////////////////////////////////////////////////////////////////////////////////
----------------Make Started: 'Application0' in configuration 'Standard'--------------------------
 
Building D:\TempSTM32\Serial.c
Running: ARM Compiler
"D:\WinXPSoft\RIDE7\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -MD -D_STM32F103ZET6_ -D_STM3x_ -D_STM32x_ -mthumb   -mcpu=cortex-m3 "D:\TempSTM32\Serial.c" -o "D:\TempSTM32\Serial.o" -I "." -I "D:\WinXPSoft\RIDE7\Ride\Lib\ARM\include" -c     -fsigned-char  -D OLD_STM32LIB_USED -g      -O1   -ffunction-sections         -mlittle-endian
"D:\WinXPSoft\RIDE7\Ride\Bin\rexrdr.exe" "D:\TempSTM32\Serial.lst" 0 "D:\WinXPSoft\RIDE7\Ride\arm-gcc\bin\arm-none-eabi-objdump.exe" --disassemble -all --source "D:\TempSTM32\Serial.o"
"D:\WinXPSoft\RIDE7\Ride\Bin\rexrdr.exe" "D:\TempSTM32\Serial.o.sizetmp" 0 "D:\WinXPSoft\RIDE7\Ride\arm-gcc\bin\arm-none-eabi-size.exe" "D:\TempSTM32\Serial.o"
 
Building D:\TempSTM32\Main.C
Running: ARM Compiler
"D:\WinXPSoft\RIDE7\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -MD -D_STM32F103ZET6_ -D_STM3x_ -D_STM32x_ -mthumb   -mcpu=cortex-m3 "D:\TempSTM32\Main.C" -o "D:\TempSTM32\Main.o" -I "." -I "D:\WinXPSoft\RIDE7\Ride\Lib\ARM\include" -c     -fsigned-char  -D OLD_STM32LIB_USED -g      -O1   -ffunction-sections         -mlittle-endian
"D:\WinXPSoft\RIDE7\Ride\Bin\rexrdr.exe" "D:\TempSTM32\Main.lst" 0 "D:\WinXPSoft\RIDE7\Ride\arm-gcc\bin\arm-none-eabi-objdump.exe" --disassemble -all --source "D:\TempSTM32\Main.o"
"D:\WinXPSoft\RIDE7\Ride\Bin\rexrdr.exe" "D:\TempSTM32\Main.o.sizetmp" 0 "D:\WinXPSoft\RIDE7\Ride\arm-gcc\bin\arm-none-eabi-size.exe" "D:\TempSTM32\Main.o"
 
Building D:\TempSTM32\Application0.rapp
Running: LD Linker
"D:\WinXPSoft\RIDE7\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker "D:\TempSTM32\Application0.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -nostartfiles -Wl,-Map -Xlinker "D:\TempSTM32\Application0.map"   
D:\TempSTM32\Main.o: In function `main': 
D:\TempSTM32/Main.C:16: undefined reference to `Serial_Comm_C()' 
d:/winxpsoft/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-abort.o): In function `abort': 
abort.c:(.text+0x8): undefined reference to `_exit' 
d:/winxpsoft/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_getpid_r': 
signalr.c:(.text+0x2): undefined reference to `_getpid' 
d:/winxpsoft/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_kill_r': 
signalr.c:(.text+0x1c): undefined reference to `_kill' 
d:/winxpsoft/ride7/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-sbrkr.o): In function `_sbrk_r': 
sbrkr.c:(.text+0x12): undefined reference to `_sbrk' 
collect2: ld returned 1 exit status 
 
Build failed
/////////////////////////////////////////////////////////////////////////////////////////

Re: Using Extern Problem

Hi,

This is a library problem. Ensure you are using the latest RKit-ARM, then disable the "UART0 putchar" capabilitie in the linker options. And also the old precompiled ST libraries if they are active.

I just tested your project and it builds fine with this.

Regards,
Bruno

Bruno Richard, PhD.
RAISONANCE - 17, avenue Jean Kuntzmann - F-38330 Montbonnot St Martin - FRANCE
There are 10 types of people in the world: Those who understand binary, and those who don't.

Re: Using Extern Problem

Hi Bruno,
I am still having the same trouble. The files are unable to compile. Is there anyway I can send you the complete project so that you can figure out the real problem.

Regards,

Nommy.

Re: Using Extern Problem

Hi Nommy,

I received your project. The problem is that your main.c file has a ".C" instead of ".c".
GCC is touchy about case sensitivity, and it thinks your file is a C++ file.

Correct the file name and it will be fine.

Regards,
Bruno

Bruno Richard, PhD.
RAISONANCE - 17, avenue Jean Kuntzmann - F-38330 Montbonnot St Martin - FRANCE
There are 10 types of people in the world: Those who understand binary, and those who don't.