Table of contents
1.
Introduction
2.
ATL Window Class
3.
CRT Libraries
4.
Effects of Linking CRT
5.
Dynamic Link Library
6.
Frequently Asked Questions
6.1.
What is ATL?
6.2.
How can CRT be linked?
6.3.
What is CRT?
6.4.
What is DLL?
7.
Conclusion
Last Updated: Mar 27, 2024

CRT in ATL

Author Ayushi Goyal
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Window development used to be very difficult. This is because we have to rewrite the same codes again and again. Then Microsoft Foundation Class (MFC) came into existence. Using MFC, developers can save their codes and use them when required. Thus, MFC saves a lot of time that was previously wasted in rewriting. But everything cannot be saved. Developers have to write some codes from scratch as well. And so, Active Template Library(ATL) comes in handy. The ATL window class is a mediator between writing code from scratch and MFC.  

Introduction

In this article, we'll learn about CRT used in the ATL project. We will also discuss the effects, benefits, and tradeoffs of linking CRT in ATL. 

ATL Window Class

ATL stands for Active Template Library. Its library contains numerous classes that can be used to manipulate and develop Windows. ATL contains a set of template-based C++ classes that help you create Component Object Model (COM) objects. ATL supports various COM features, including -

features

The presence of these features makes ATL highly recommended for creating software components. We are done with learning the ATL Window Class. Now, we let's have a look at the CRT Libraries. 

CRT Libraries

CRT stands for C Run-Time Libraries. It is a collection of useful functions that are required in building a program. It makes ATL development much easier for programmers. The functions are basically categorized into 2 types. These are -

  • C Standard Library Functions - All the functions present in C standard library come under this category. These functions are - heap functions, memory functions, string functions, and formatted IO functions. For example - memcpy, memset, alloc, free, snprintf, sscanf, etc.
     
  • Compiler-specific auxiliary functions - The functions that are highly dependent on compiler and architecture come under this category. Compiler-specific functions supply the functionalities provided by standard functions. These functions are mainly used for cryptography algorithms. 
CRT Libraries

As all the ATL projects are linked to CRT libraries. CRT can be linked either dynamically or statically. So, let's see what the effects of both types of linking of CRT Libraries are. 

Effects of Linking CRT

If CRT Libraries are linked statically, then the CRT code is placed in an executable image. The image size, in this case, is around 25K. The benefit of statically linking the CRT libraries is that users don’t need DLL(Dynamic Link Library) on their systems. As stated above, static linking leads to increasing image size. So this is the biggest tradeoff of static linking.  

If CRT Libraries are linked dynamically, then instead of code, references to the codes are placed in the executable image. As most of the code is present on the DLL, the image size is small. Dynamic linking is preferred because it does not require any startup code. Thus, the image size can be kept small. The tradeoff of dynamic linking is that, in order to run your image, CRT DLL must be present in your system. 

These executable images specify an entry point in Operating System. This specification can be done either implicitly or explicitly. For example - the default entry point for DLL is - DllMainCRTStartup. CRT provides the implementation of all these entry points. These entry points call constructors on global objects. Then the data structures used by the CRT function are initialized at these entry points. 

Dynamic Link Library

A DLL stands for Dynamic Link Library. It is a library containing data and code that many programs can use simultaneously. Each program can use the functionality present in DLL to implement various operations. It also helps in efficient memory usage and code reusability. DLL also supports the modularization of separate components of a program. If these modules are installed, they can easily be loaded into the main program. 

DLL

The modularization concepts make the load time faster. DLL provides several benefits to ATL projects. These are- 

  • DLL removes duplication of the code. Hence, it reduces resource utilization.
  • DLL helps in creating modular structures which are easy to understand. 
  • DLL provides multiple programs that can fix and update the program.

Frequently Asked Questions

What is ATL?

ATL stands for Active Template Library. It is a library containing numerous classes that can be used to manipulate and develop Windows.

How can CRT be linked?

There are two ways to link CRT. These are - static linking(Single-Threaded) and Dynamic Linking(Multi-Threaded). 

What is CRT?

CRT stands for C Run-Time Libraries. It is a collection of valuable functions required to build a program. It makes ATL development much easier for programmers. 

What is DLL?

A DLL stands for Dynamic Link Library. It is a library containing data and code that many programs can use simultaneously.

Conclusion

In this article, we have discussed the C Run-Time libraries in ATL. We also discuss the ATL window class and the effects of linking CRT. And, at last, we discussed what  Dynamic Link Libraries are.  

Do not stop learning! We recommend you read these articles -. 

  1. Debugging tips for ATL
  2. ATL Control Containment
  3. ATL Services
  4. ATL COM property pages
  5. Ternary Operator in C
     

Please refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. And also, enroll in our courses and refer to the mock test and problems available. Have a look at the interview experiences and interview bundle for placement preparations.
Keep learning, and Keep Growing!

Do upvote our blogs if you find them engaging and knowledgeable.

Live masterclass