Keil™, An ARM® Company

Technical Support

µVISION1: INCLUDING OBJECT FILES IN LINK


Information in this article applies to:

  • µVision Version 1
  • C51 Version 5.50

QUESTION

My project consists of two source files, SOURCE1.C and SOURCE2.C. When these are compiled, I link them with some object files that were built in another project, EXTERN1.OBJ through EXTERN3.OBJ.

The way I currently build my project is to run a batch file, which compiles the source files, and call the linker using the following linker command file:

EXTERN1.OBJ, &
EXTERN2.OBJ, &
EXTERN3.OBJ, &
SOURCE1.OBJ, &
SOURCE2.OBJ, &
TO OUTPUT
RAMSIZE(0FFh)
PDATA(0400h)
XDATA(0400h)

I tried to create a µVision project which included the two source files and called the linker command file, however, I get an error when it tries to link. How do I convert my batch file based project to a µVision project?

ANSWER

When using µVision, the linker command file may only contain directives, not lists of object files or an output file, so the first thing to do is change your linker command file to:

RAMSIZE(0FFh)
PDATA(0400h)
XDATA(0400h)

Next, you need to add the object files to your project in such a way that they are only linked, not compiled or assembled (translated).

Complete the following steps for each object file:

  • Choose Edit Project from the Project menu.
  • Click on Add and choose an object file. Click on OK.
  • µVision will state that it does not know which translator to use. You may ignore this message.
  • Select the object file in the list of Source files.
  • Uncheck the option 'Always build' and check the option 'Include in link/lib'. Set the translator set to 'Library File'.
  • Click on Save.

You will now be able to build your project successfully. Note that you should not add object files in this way if they are generated from a source file that is already included in the project. The result is that the object file will be linked twice, generating errors.

MORE INFORMATION

See also: µVision1: LINKER COMMAND AND RESPONSE FILES

Last Reviewed: Tuesday, June 15, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure