Header and C files included... but keep getting "undefinied reference to"

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Header and C files included... but keep getting "undefinied reference to"

2,334 Views
es483
Contributor II

Dear NXP users,

I'm having from a few days a problem that I wasn't able to solve, and to which I can't find any solution.

I downloaded, after registering, the following example code from the Micrium uC-OS website: FRDM-K64F_OS3-TCPIP-HTTPs-DHCPc-KSDK-LIB | Micrium 

The problem is that the project is already present only for IAR and Keil, but I need to work with KDS only.

I tested the project on a 30-days trial version of IAR, and it works perfectly.

Then, I tried adding the files I needed to an existing project in KDS, copying them in the correct folders and linking them to the KDS project.

The problem is the following: everything compiles... until I call some function that references to the library! In that case I keep getting "undefined reference to..." to functions that are defined in .h/.c files that are included!

After calling, for instante, AppTCPIP_Init(), that is a function provided by the library uC-TCP/IP, I cannot compile anymore.
For example, inside "app_dhcp-c.c" there's a function call:

            dhcp_status = DHCPc_ChkStatus(if_nbr, &err_dhcp);

The compiler tells me:

         "Undefined reference to 'DHCPc_ChkStatus'"

While DHCPc_ChkStatus() is definied in "dhcp-c.h", that is included though a chain of header files. Also including it directly by adding:

#include "dhcp-c.h"

does not change the situation at all.

Please help, I really need to be able to launch soon this project in KDS.

What am I missing?

Thanks a lot in advance!

Labels (1)
0 Kudos
6 Replies

1,404 Views
es483
Contributor II

Hi!

I'm answering as a reply to the original answer since I have a few more information.

First of all... thanks!

I tried importing everything as manually as possible inside KDS, and I followed again the guide you linked to me, adding the lib name, lib path and all the needed .h files. I also checked if all the needed files are there, and they should be there.

However, the library is correctly recognized, but I'm still getting these errors, that seems to come directly from inside the .a library:

pastedImage_1.png

Mem_Copy is by the way defined, and inside IAR in fact everything compiles correctly.

Why am I not able to use the very same library inside KDS?

Thanks in advance!

0 Kudos

1,404 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi,

The method for adding  lib into KDS works well , I test it as Erich said.

While sorry I know this demo you provide little, maybe you can ask the

Micrium about this problem.

BR

Alice

0 Kudos

1,404 Views
es483
Contributor II

Thank you very much!

I'll try asking Micrium about that.

0 Kudos

1,404 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Francesco Raviglione ,

How about add the lib name and path in KDS ?

You can refer to the below thread to do it:

Creating and using Libraries with ARM gcc and Eclipse | MCU on Eclipse 

Hope it helps,

Alice

0 Kudos

1,404 Views
es483
Contributor II

Hello,

Thank you very much for your reply!

I just found out that this error was probably happening because most .c files are in fact packed inside a pre-compiled ".a" library, and so, without including it, the function were only present in the .h files, thus the "undefined reference" errors.
I tried importing it, but I get some "most undefinded references to xxxxxxx follow" errors coming from the external library! I fear these errors come from the fact that this library has been generated for the IAR compiler, not for GCC.
In the IAR project there's also a IAR compiler specific .asm file, that I cannot import in KDS... so... I think more research has to be done in order to understand if it possibile to use this in KDS... or not!

Thanks again!

0 Kudos

1,404 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Francesco Raviglione,

- I haven't use the KDS on uC-OS , I think its the same.

On KDS, if you want use the .a lib , you only need refer to the guide I mentioned last time to do it.

Add the lib name , lib path, also the .h path.

- About the compiler problem,  I recommend you create a new blank project on KDS, then add the lib , copy application codes . Or it hard to solve problem.

BR

Alice

0 Kudos