Solved

Why build success when lib linked and lib files compiled ?

Posted on 2014-02-24
4
709 Views
Last Modified: 2014-02-24
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:

C:\Keil\ARM\RV31\LIB\RTX_ARM_L.LIB
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:

rt_Event.c
HAL_ARM.c
...

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 ?
0
Comment
Question by:naseeam
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 39884343
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.
0
 
LVL 1

Author Comment

by:naseeam
ID: 39884398
>> 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 ?
0
 
LVL 86

Expert Comment

by:jkr
ID: 39884563
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).
0
 
LVL 1

Author Closing Comment

by:naseeam
ID: 39884606
Very Fast and useful response.  Great explanation of follow-up question.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question