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

How to use a self created library in Keil C ?

How to use a self created library and the default *.lib in Keil C ?
and which and how to setup a default *.lib such as the following - c51s.lib ? c51L.lib ? c51c.lib ?

=======================================
i have create a header file myfirst.h
=======================================
#pragma SAVE
#pragma REGPARMS
extern char returndummychar(void);
#pragma RESTORE

========================================
and the source code myfirst.c
========================================
char returndummychar(void)
{
return('a');
}

========================================
I compile the file and have myfirst.obj
========================================

lib51 create myfirst.lib
lib51 add myfirst.obj to myfirst.lib

============================================
All the above steps are done. now, how to include the myfirst.lib in a new C
project ??

Thank you very much !

Parents
  • myfirst.h
    ==========================
    #pragma SAVE
    #pragma REGPARMS
    extern char myfirst(void);
    #pragma RESTORE

    myfirst.c
    =========================
    char myfirst(void)
    {
    return('a');
    }

    =========================
    lib51 add myfirst.obj to myfirst.lib
    =========================

    I add the myfirst.lib to my project folder named maintest .

    maintest.c
    ===================
    #include <myfirst.h>
    void main(void) {
    unsigned char i,b;
    for (i=0;i<100;i++)
    { b=myfirst(); }
    }

    Linker ....
    WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL : MYFIRST
    MODULE : MAINTEST.OBJ (MAINTEST)
    WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL SYMBOL
    SYMBOL : MYFIRST
    MODULE : MAINTEST.OBJ (MAINTEST)
    ADDRESS : 0007H
    "MAINTEST" - O ERRORS, 2 WARNINGS

    WHY?
    Please help !

Reply
  • myfirst.h
    ==========================
    #pragma SAVE
    #pragma REGPARMS
    extern char myfirst(void);
    #pragma RESTORE

    myfirst.c
    =========================
    char myfirst(void)
    {
    return('a');
    }

    =========================
    lib51 add myfirst.obj to myfirst.lib
    =========================

    I add the myfirst.lib to my project folder named maintest .

    maintest.c
    ===================
    #include <myfirst.h>
    void main(void) {
    unsigned char i,b;
    for (i=0;i<100;i++)
    { b=myfirst(); }
    }

    Linker ....
    WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL : MYFIRST
    MODULE : MAINTEST.OBJ (MAINTEST)
    WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL SYMBOL
    SYMBOL : MYFIRST
    MODULE : MAINTEST.OBJ (MAINTEST)
    ADDRESS : 0007H
    "MAINTEST" - O ERRORS, 2 WARNINGS

    WHY?
    Please help !

Children