cancel
Showing results for 
Search instead for 
Did you mean: 

Eclipse: undefined reference to

AShva.1
Associate II

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

10 REPLIES 10
ArmandG
ST Employee

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.1
Associate II

Hi Armand!

done

Same error :(

0693W000000VN9rQAG.png

Regards

Alexander/

ArmandG
ST Employee

​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.1
Associate II

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

ArmandG
ST Employee

​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.1
Associate II

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

Piranha
Chief II

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

AShva.1
Associate II

Hi Piranha !

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

Сan you advise something?

Regards

Alexander

Piranha
Chief II

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.