Hi, I am trying to create a library file to make some of the functions generic. I need to know how to create it and link it with my source code in C using uvision for c51 & 8051 developments.
"make some of the functions generic." What exactly do you mean by that? Putting files into a library will not make them any more or less generic.
Actually the requirement is to have a common library which can be used for specific functionality such as network connection, message routing etc. This will exactly act as sin, cos or log functions included in math library. I want to include it as .LIB file in my project I had tried generating one by selecting create library in options for target output dialog and included this file in my main project but all the time I am getting a compile error related to this .LIB file.
"all the time I am getting a compile error related to this .LIB file." So how do you expect anyone to hepl you if you don't actually state what error you are getting??!! Post the full text of the complete message - use cut-&-paste; do not re-type it.
Here are the details of the error I am getting, I have created a separate project where I have written a small function which accepts an integer value does some calculations and returns back the result. I have selected the target processor and in the project settings for output I have selected create library option. I have named this file as MyLib.c and I am able to generate a MyLib.Lib file after compiling the program. I am calling this function from my main project (program) where I have included this MyLib.lib file. The details of the Function and error are as under. int return_no(int value) { int i = value * 5; return(i); } I have named this file as MYLIB.C and in the project setting I have selected the target processor MYLIB.LIB(1): error C100: unprintable character 0xAC skipped MYLIB.LIB(1): error C100: unprintable character 0x07 skipped MYLIB.LIB(3): error C141: syntax error near '?' MYLIB.LIB(3): error C100: unprintable character 0x16 skipped MYLIB.LIB(3): error C100: unprintable character 0xC8 skipped MYLIB.LIB(3): error C100: unprintable character 0x08 skipped MYLIB.LIB(4): error C129: missing ';' before '?' MyLib.LIB(10): error C305: unterminated string/char const I have not exposed these details earlier because I wanted to know exactly how to create a lib file (is there any other way) and access it from the program. Thanks for the help
You cannot include a lib into a compiler source. Once you have created a library file, you may add this library file to another project just in the same way as you add source files to a project. Reinhard
As Reinhard says, you cannot compile a Library! A Library contains compiled object code - it is not a 'C' source file! A Library provides an input to the Linker - not to the compiler! Look at the Diagram of the "Software Development Cycle" in Chapter 1 of the uVision-2 Getting Started Guide (p13 in the 02.2001 version).