Why do I need to install the c++ redistribution package?

Asked 2 years ago, Updated 2 years ago, 23 views

Why do you have to install that separately from the user's point of view when you sometimes ask for a runtime package when you run a program developed with c++? Isn't it not a native language if the developer can't put everything into the program in the process of compiling?

c++

2022-09-22 20:21

2 Answers

I've never had that experience with C++, but I'm answering in light of my experience in other languages.

There are teachers and students.

The teacher asked me to implement A+B, and one team decided to implement A and student 2 to implement B.

What you're talking about is

Shouldn't you take the student 2 code and evaluate it if you make it from student 1's point of view and submit it?

It's similar to that.

The compiler is not that kind. For the compiler, the other runtime package is just student 2's code. Of course, student 2's code must be bundled and submitted, and the process is the process of installing the package

It's annoying to manage the package. So we use a variety of tools to manage packages. I don't know what's available in C++.


2022-09-22 20:21

I supplement it a little bit more under the assumption that it's Windows.

There are two main types of libraries: static type and dynamic type.

Here, the static type is lib or a extension, and when compiling, it all adds up to create one large file.

The dynamic type has a dll or so extension and is used by dynamically invoking the library.

A runtime library, which is a common library for running. It is common as a library that is commonly used in mfc-based programs, so it is distributed by dll and loaded dynamically.

Because the runtime library is a common library, all executable files must be loaded. If you make those libraries static, it means that all executable files have the same library.

First, the maintenance is poor. A bug was found in the common library. If it was a static type, you will need to recompile it for patching. However, if it is a runtime library, you only need to update the library.

Second, it is a waste of memory. For dll, it is committed only once to memory. If two executable files use the same dll, only the dll memory space is mapped to the virtual memory space.

If it is dynamic, it will occupy only once, but if it is static, it will occupy memory.

Third, it's a waste of disk.
If it is static, it will be added to one file, so of course the size will be bigger. If you use the same library in 10 programs, it's a waste.

And of course, there's also a drawback, which is a library crash problem called dll hell, or static, which is faster than dynamic.


2022-09-22 20:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.