| Details | Message |
|---|
Read-Only Author simon pinaculu Posted 28-Jul-2003 05:06 GMT Toolset C51 |  How to use a self created library in Keil C ? simon pinaculu 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 ! |
|
Read-Only Author Stefan Fricke Posted 28-Jul-2003 06:35 GMT Toolset C51 |  RE: How to use a self created library in Keil C ? Stefan Fricke Hi Simon,
simply add the *.lib to your project. With the one difference. As extension choose *.lib and as file type library file.
Ready for use !
Stefan |
|
Read-Only Author simon pinaculu Posted 28-Jul-2003 09:22 GMT Toolset C51 |  RE: How to use a self created library in Keil C ? simon pinaculu I add the myfirst.lib to my project 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 ! |
|
Read-Only Author simon pinaculu Posted 28-Jul-2003 09:30 GMT Toolset C51 |  RE: How to use a self created library in Keil C ? simon pinaculu 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 ! |
|
Read-Only Author Jon Ward Posted 28-Jul-2003 15:29 GMT Toolset C51 |  RE: How to use a self created library in Keil C ? Jon Ward I add the myfirst.lib to my project folder named maintest.
Did you add the .LIB file to the project and not just to the project folder? The linker needs to know the name of the library file.
Also, make sure that you specify libraries last in your project. Refer to http://www.keil.com/support/docs/1220.htm for more information about that.
Jon |
|
Read-Only Author chao lin Posted 29-Jul-2003 06:24 GMT Toolset C51 |  RE: How to use a self created library in Keil C ? chao lin You can try the method mentioned in http://www.keil.com/support/docs/634.htm. This artical is about how to use library functions.
chao. |
|
Read-Only Author Hans-Bernhard Broeker Posted 4-Aug-2003 12:50 GMT Toolset C51 |  RE: How to use a self created library in Keil C ? Hans-Bernhard Broeker I see a potential bug in your library function's source code.
You don't #include the header file (myfirst.h) into the source code (myfirst.c). You should always do that, to enable the compiler to warn you about mismatches between the header and the implementation.
Actually, I'm quite sure the definition of function myfirst() in myfirst.c is incompatible to its declaration in myfirst.h, and that's the real reason for the linker error messages you got. |
|
Read-Only Author Holger Warzelhan Posted 4-Aug-2003 16:45 GMT Toolset C51 |  RE: How to use a self created library in Keil C ? Holger Warzelhan You have created a function named returndummychar(), but you try to call a function named myfirst(), which doesn't exist in your project. Myfirst is the library name and not the function name you want to call. Holger |
|