Where does compiler/linker look for this *.obj file?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Where does compiler/linker look for this *.obj file?

Jump to solution
1,567 Views
leesp
Contributor I

Hi,

I am using CW for MC9S08. I don't understand how the compiler/Linker look for the *.obj file.

 

I first created my project in CW with 2 source files, main.c and myfunc.c. After I MAKE, I purposely remove the myfunc.c from the project. However I leave the object files (main.c.o & myfunc.c.o) intact in my directory C:\Project1\Project1_Data\Standard\ObjectCode\

 

Then I MAKE again. It gives me a LINK error saying that particular function in myfunc.c is undefined.

 

Why is this so? I thought even if the myfunc.c is not included in the project, but as long as the previously compiled myfunc.c.o is present, the compiler/Linker should be able to find it?

Labels (1)
Tags (1)
0 Kudos
1 Solution
579 Views
CrasyCat
Specialist III

Hello

 

This is a normal behavior for the IDE.

 

When you start building a project, the IDE will first evaluate whether the object files (.o) are up to date.

In order to check that it will compare the modification date of the .c files and all files included in there with the modification date of the object file.

 

If the source file is not available this cannot be done and CodeWarrior is not able to build (make) the project.

If you have all the object files available, you may want to start the link process through command line.

This will not require any source or header file.

 

CrasyCat

View solution in original post

0 Kudos
2 Replies
580 Views
CrasyCat
Specialist III

Hello

 

This is a normal behavior for the IDE.

 

When you start building a project, the IDE will first evaluate whether the object files (.o) are up to date.

In order to check that it will compare the modification date of the .c files and all files included in there with the modification date of the object file.

 

If the source file is not available this cannot be done and CodeWarrior is not able to build (make) the project.

If you have all the object files available, you may want to start the link process through command line.

This will not require any source or header file.

 

CrasyCat

0 Kudos
579 Views
NavidadRedivivu
Contributor III

This happens because the IDE explicitly passes all the names of the object files to the linker in the command line (via the -Add option). If you are trying to learn about the linker user interface, it may be a good idea to review the command lines the IDE generates. If you are using MCU 10.0 they simply show in the console. If you are using CW 6.x then you need to check 'Display generated command line' (or something of the sort) in the linker preference panel. Note that the -Add option is just an alternative to filling in the NAMES block in the linker parameter file (.PRM).

There is such a thing as "path where the linker searches for .obj files" but the answer to your question is not related to it. You can define an environment variable to control this: OBJPATH.

0 Kudos