Skip to main content
Visitor II
April 4, 2020
Question

Eclipse: undefined reference to

  • April 4, 2020
  • 9 replies
  • 2585 views

Hi!

I am trying to compile a project from several files in Eclipse.

Function print_hello() defined in another file N222.

Resulting error: undefined reference to `print_hello '

What am I doing wrong?

 0693W000000VK3bQAG.png

regards

Alexander

    This topic has been closed for replies.

    9 replies

    ST Employee
    April 6, 2020

    Hi @JulianSTMhvalev​ ,

    In your 222.c you have to write "extern void print_hello();"​ at the 13rd line otherwise it cannot recognize the function.

    Regards,

    Armand

    AShva.1Author
    Visitor II
    April 6, 2020

    Hi Armand!

    done

    Same error :(

    0693W000000VN9rQAG.png

    Regards

    Alexander/

    ST Employee
    April 6, 2020

    ​Hi Alexander,

    Is it working if you create a 222N.h header file where you define the hello_world function ?

    Don't forget to include it in both files 222.c and 222N.c

    Regards,

    Armand

    AShva.1Author
    Visitor II
    April 6, 2020

    Hi Armand!

    done

    Same error :(

    0693W000000VNIKQA4.png

    Eclipse IDE for C/C++ Developers

    Version: 2020-03 (4.15.0)

    Build id: 20200313-1211

    Regards

    Alexander

    ST Employee
    April 6, 2020

    ​Hi Alexander,

    On our side it's still working on Eclipse with your code. Are you sure the 222N.c file is well implemented in your project ? Because on the console, it seems like only the main file 222.c is compiled and not the 222N.c file, that's why it doesn't recognize the function. I suggest you to refresh the project to make sure the file is well implemented. By the way, what are your compiler / linker settings on Eclipse ?

    Regards,

    Armand

    AShva.1Author
    Visitor II
    April 7, 2020

    Hi Armand!

    thank you for your help

    I also think something is wrong in the linker or compiler settings

    settings:

    0693W000000VQqyQAG.png

    compiler:

    -I/home/alexsander/STM32MPU_workspace/STM32MP15-Ecosystem-v1.2.0/Developer-Package/SDK/sysroots/x86_64-ostl_sdk-linux/usr/include -I/home/alexsander/eclipse-workspace/222/inc -O0 -g3 -Wall --sysroot=/home/alexsander/STM32MPU_workspace/STM32MP15-Ecosystem-v1.2.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7

    0693W000000VQr3QAG.png

    linker:

    -nostartfiles -L/home/alexsander/eclipse-workspace/222/src --sysroot=/home/alexsander/STM32MPU_workspace/STM32MP15-Ecosystem-v1.2.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi -marm -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7

    0693W000000VQr8QAG.png

    I will be glad to your prompts :)

    Regards

    Alexander

    Graduate II
    April 7, 2020

    Look at the log after "make all" command - file "222N.c" is not compiled at all. You have to sort out that.

    AShva.1Author
    Visitor II
    April 7, 2020

    Hi Piranha !

    I'm looking for an answer on how to do this.

    Сan you advise something?

    Regards

    Alexander

    Graduate II
    April 8, 2020

    So what have you done yourself while "looking"? Checked paths, file properties, compiler configuration?

    I don't like Eclipse and use EmBitz instead... Probably @Pavel A.​ can give some advice.

    Super User
    April 9, 2020

    Indeed it looks like the file "222N.c" is not compiled at all.

    Try to refresh the project, clean and rebuild.

    If this won't help, ask your instructor to help (it is a student project?)

    -- pa