undefined reference to `time'

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

undefined reference to `time'

Jump to solution
6,188 Views
armendgecaj
Contributor III

Hi all,

 

i have a qeustion. Maybe somebody can help me.

 

I wrote an algorithm in the language C. My algorithm create a random labyrinth. I used the function "srand((unsigned)time(NULL));". With this function i ensure that my labyrinth is really random (otherwise i get always the same labyrinth, for more information about "srand((unsigned)time(NULL));" see srand - C++ Reference ).

Additional i add the Header file " #include<stdlib.h> " and " #include<time.h> ". Now i can use the function srand(.......).

 

If i build my algorithm in Microsoft Visual i get no problems.

But if i copy my algorithm in CodeWarrior and build it then i get the problem report " undefined reference to `time' ".

But i used the header file time.h and in microsoft visual it works.

 

Have anybody an idea why i become this problem report in CodeWarrior, and what can i do?

 

 

Thank you very much!

 

Best Regards

Armend

Labels (1)
1 Solution
3,649 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Armend,

1 . It means there is no driver for the function of time , you need write the function specific to your device .

"The ANSI library provides several functions to get the current time. In an embedded systems environment, implementations for these functions cannot be provided because different targets may use different ways to count the time."

2. About the SRAM memory , even through  after you change the length , there is no error when you build ,

while this is still can not run correctly , for the mcu only have 128K SRAM,  if the data bigger than that , where does the data placed ?

Hope it helps

Alice

View solution in original post

10 Replies
3,649 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Armend,

Which version of CW ? And which chip ?

Could you please send your project to me ?

BR

Alice

0 Kudos
3,649 Views
armendgecaj
Contributor III

Hello Alice,

thank you for your help.

I am working with CodeWarrior for MCU v10.6 and with the Microcontroller Kinetis K60F (MK60FN1M0).

I dont know how to send you my Project because i can not find the button for an attachment. 

And i can not upload my project in my profile because i become a problem report (i have no right to upload something). Confusing!

So maybe you can give me your E-Mail Adress and i will send you my project.

Or have you another idea?

Best Regards

Armend

0 Kudos
3,649 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Armend,

You can create one simple project , then only use the code which can reflect the  problem.

You can click the "Actions" button to send attachment , or you can send it to my email:

alice.yang@nxp.com 

BR

Alice

0 Kudos
3,649 Views
armendgecaj
Contributor III

Hi Alice,

i sent my project as a zip-file to your E-Mail adress.

Unfortunately, i could not send you my project here on this website because i dont find the button to send an attachment.

If i click on "Actions" there is no button for attachment. Maybe i can only send an attachment if i ask a question (this one i tried before),

but not if answer.

Best Regards

Armend

0 Kudos
3,649 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Armend,

I have checked your project, the root reason is the code overflowed .

For the chip of MK60FN1M0 only have 128K SRAM, while your m_data is 550416 bytes, it is 537K .

pastedImage_1.png

pastedImage_2.png

You can relocate the large data to FLASH, refer to this DOC :

Relocating Code and Data Using the CW GCC Linker File for Kinetis   

Hope it helps


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
3,649 Views
armendgecaj
Contributor III

Hi Alice,

i forget to tell you that if you build my project you will become a "overflowed-problem"

But i already fixed this problem. If you go to Project_Settings --> Linker_Files --> ProcessorExpert.Id, you can enlarge 'm_data'.

Only changing the LENGTH of 'm_data' and the "overflowed-problem" will be fixed (see the image i attached)

m_data.png

But have you any idea how to fix the problem: 'undefined reference to time'. This is coming from the function 'srand((unsigned)time(NULL))'.

I find this post: "The CodeWarrior libraries provide the time functions as are standard but these does not come with the low level functions for the operations, as stated on the MSL C reference manual".

I understand it but what have i exactly to do now to fix the problem.

I would be grateful if you (or somebody else) give me a hint.

Best Regards

Armend Gecaj

0 Kudos
3,649 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Armend,

- The maximum size of the RAM about the chip of MK60FN1M0VLQ12  is 128KB 。

pastedImage_1.png

While from the  m_data is 550416 bytes, it is 537KB, so how length do you can change to meet the 537KB?

- I have not used the "time" , please tell me where can find the post you said .

BR

Alice

0 Kudos
3,649 Views
armendgecaj
Contributor III

Hi Alice

You asked: "[...], so how length do you can change to meet the 537 KB?"

Well, i enlarged 'm_data' from LENGTH = 0x0000FE18 to LENGTH = 0x000AFE18.

If i do that then the overflowed-problem will be fixed.

The post about the header file "time.h" is here: How to use clock_t with time.h header file 

But i do not really understand what this user is trying to say.

Best Regards

Armend

0 Kudos
3,650 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Armend,

1 . It means there is no driver for the function of time , you need write the function specific to your device .

"The ANSI library provides several functions to get the current time. In an embedded systems environment, implementations for these functions cannot be provided because different targets may use different ways to count the time."

2. About the SRAM memory , even through  after you change the length , there is no error when you build ,

while this is still can not run correctly , for the mcu only have 128K SRAM,  if the data bigger than that , where does the data placed ?

Hope it helps

Alice

3,649 Views
armendgecaj
Contributor III

Hi Alice,

Ok now i understand. I need to create a Driver to use time (for 'srand((unsigned)time(NULL))'). Thank you.

To the second point (SRAM Memory) you are right. Even if i change 'm_data' so that i get no error message, it does not work.

But i have fixed this problem already. I have changed my function a little bit.

Best Regards

Armend

0 Kudos