Why build success when lib linked and lib files compiled ?

I'm using Keil uVision version 4.73.  In my Options for Target I select RTX Kernel Operating System.  This selection will add following to the Linker Control String in the Linker Tab:

This means this operating system library will be linked when I build my project.  In addition to linking this library, I have added all files used to create this library to my project as follows:


These files are in  C:\Keil\ARM\RL\RTX\SRC\ARM  folder.

Why does my build work ?   I'm including same Operating System twice.  Shouldn't I get re-defined symbols ?
Who is Participating?
jkrConnect With a Mentor Commented:
When you have all these files in your project, there are no dependancies to resolve. A linker will only use these functions from a static library that are referenced from your code, Since there are none, the linker will not look for them in the lib file.
naseeamAuthor Commented:
>> there are no dependencies to resolve
I want to make sure I understand.  If I call foo ( ) from my code, and foo is implemented in one of the project files, then, foo implementation from my project file will be part of executeable.  Identical Foo implementation from library file will be ignored ?
Yes, that's exactly it. Code from static libraries will only be used on a 'as needed' basis. Never will the entire library be added to your executable (well unles really all functions are used).
naseeamAuthor Commented:
Very Fast and useful response.  Great explanation of follow-up question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.