This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Weird error with mktime..

Hi,

I'm using uVision 3,23 with CA.exe (compiler) V2.41 and LA.exe (linker) 2.41. The program compiles, but with the linking run, I get errors;

*** WARNING L23: UNRESOLVED EXTERNAL SYMBOLS
*** ERROR L128: REFERENCE MADE TO UNRESOLVED EXTERNAL SYMBOL: mktime?T ADDRESS: 200023B4H

... :S. I've tried I guess everything. This error happens with the line:

  time_t TIME;
  struct tm *ptim;
  /* the rest of my code... */
TIME = mktime(ptim)-0x3FF36300;

.

If I comment that line, the linker does the linkiing fine. The mktime() is declared in time.h, and the file is included. When I put the decleration in the local file; same error.. I don't know what to do anymore :S. Any ideas?
The microcontroller is a STR7 and the code is for sync the hardware-RTC with the current time..

Thank you so so very much..

Jay.

  • The header file just tells the compiler that a function matching the prototype will be provided by some external means.

    It's up to you to ensure that you make good on that promise by providing the actual function itself to the Linker - either from another source file, or from a Library...

  • Are you using microlib? Are you sure that mktime() is available in the microlib?

    The header file just tells the function prototype. The linker error on the other hand says that you have not supplied any implementation of a function named mktime() - either because a library isn't linked, or the library doesn't contain any such function.

  • But.. But..

    mktime() is a ANSI-standard-function, right? The compiler should get it and translate it for me.. right? :S

    Thanks for the replies anyway...

  • True, but you're using an embedded toolset - and these often omit some of the standard functions.

    Have you specifically checked that mktime isn't on the "not implemented" list - especially, as already noted, if you're using the microlib...?

  • First of all; thnx for your help!

    second; I guess (I'm pretty sure) I don't use microlib.. And.. this page (from the keil-site) says that "mktime() can be used immediately": http://www.keil.com/support/man/docs/armlib/armlib_chdfdcai.htm

    And.. I'm searching for two days or something, and nothing on the keil-site or other sites says that I cannot use mktime().

    The code I use is from an example from ST, an application note for the RTC in the ST71x.. So.. I suppose it should work...

    Thnx for your time!!

  • Yes, I am using mktime() ok with the full library. I did not have to do anything extra to get it to work.

    And it is the full library that says that mktime() and localtime() can be used immediately, but that functions like time() require you to implement code to interface with the RTC of your specific hardware.

    But before writing my previous post, I did look in the library manual but failed to find out if mktime() is or isn't available in the microlib or if the text "mktime() can be used immediately" is only applicable for the full library. That was the reason I asked if you used the microlib.

    One other thing: Are you compiling C or C++? Might you have a problem where the linker looks for a name-mangled variant of mktime()? C header files should contain extern "C" { ... } to make sure that the compiler uses the C naming convention and not the C++ naming convention for the external references.

  • Hm.

    First; here's my story.. I wanted to use the rtc, and I didn't know how to use it, so I've searched for a C-example. I've found one and implemented it in my own code. Then I realised I needed time.h, which Keil didn't provide with uVision. I found one on the ST-forum, which is in ANSI-c and ARM-limited. And when I use it, I get no errors, no warnings, just an error with the linking stage....

    I program in ANSII-C, I've checked, re-checked and double-checked all function names, variables arguments, structs, pointers, everything, I'm not using microlib and.. The linking-problem with mktime drives me crazy.. :S

    Thnx.

  • Here is something to think about.

    If you have written partial support yourself, you may have used a symbol name that is clashing with a symbol name of one of the object files in the library, this blocking the linker from linking in the object file that contains mktime().

    I was in a hurry myself, so I never had the time to read how to get time() to work. I just created my own 1s interrupt for internal timing and when I need time, I use mktime() on this 1s variable. On startup, the initial value is loaded from the RTC.

  • Hi,

    I am trying to use the RTC of LPC2378 and the RTX kernel of KEIL.

    After reading this thread, I started to study the mktime() and localtime().

    The return value of localtime() looks strange to me. After some further study, I found another function, localtime_r(), "which is thread-safe and returns values in a user-supplied buffer instead of possibly using a static data area that may be overwritten by each call."

    To define/reduce the Task stack size of RTX is difficult to someone like me. My question is: if I use
    localtime() in one Task, does it need larger Task stack size?

    It seems that snprintf() needs a larger Task stack size. If this is true, then why? does snprintf() also use a static data area?

  • Per Westermark,

    I've tried almost every time.h header file I could find.. But.. Still no luck. Yesterday you said that you use mktime() ok, with no extra work. Can you please send me your time.h or/and your implementation of it.. Because I cannot get it work, and it looks like I need using mktime.. :S.

    Thank you very very much.

    Jay.

  • I don't know much about this. But according to your post, you told us that: "I'm using uVision 3,23 with CA.exe (compiler) V2.41 and LA.exe (linker) 2.41."

    I think what you use is this:

    http://www.keil.com/support/man/docs/ca/ca_library.htm
    

    There are no "time.h" and "mktime()" in CA.