You'll find out if you try, but it's a basic thing, so I'd like to ask you how it works.
However, I'm not sure what will happen to Linux's .so because I don't know enough. Linux's .so (Shared Object) seems to work as a mechanism for coexisting different versions of libraries, for example, as described below.
A shared library is a library that is loaded when a program starts. Once the shared library is properly installed, all subsequent programs will automatically use the new shared library. In fact, it's much more flexible and sophisticated than this, because the way Linux enables shared libraries to:
However, if the same version of .so is loaded on the system by starting the main program that started in one terminal window, how does .so in this "submodule" that initializes itself by referring to the environment variable if you start the main program by giving a different terminal window?There are probably only two answers.
I would appreciate it if you could let me know what the above will be like above.
普段 I don't usually work very close to the OS, so I think the usage of the term may be inappropriate, but I appreciate your cooperation.
[Additional note: 2020-10-11]
When I ask this kind of question, after receiving comments and answers, I realize the inaccuracy of my questioning method. I was only thinking about .dll and .so specific static data. I'm very sorry to those who already answered, but I added parts that should have been written in italics and bold.
That's it
linux windows dll
It's a generalization because Oira doesn't know what she doesn't understand.
Shared libraries share only where they can (=not rewrite)—that is, code (where x86 relates to CS
)—data is not shared.Just as each thread creates a stack, each process creates a separate data area (whether the data comes from EXE or DLL/so).
-----shared.c----
int global_variable;// Data is created differently for each process
void set_func(intval) {global_variable=val;} // code is shared
static
data is also part of the data, so there is no difference in the situation that each process is created separately.The idea is that data areas exist for each process (including static
data areas and heap areas used by malloc()
), not EXE
dedicated data areas and DLL
. linux does not have a dedicated data area and a dedicated data area for a.out
libhoge.so.
# If you use the same DLL
to share data between different EXE
, that's the only difference
There is no special connection between the environment variable and the dynamic link library.
Handling environment variables in the process implemented as DLLs is
It is synonymous with dealing with environment variables in the process implemented as exe.
So what the questioner wants to understand is the difference between Windows and Linux environment variables.
Environment variables are basically determined by the process unit, but
For Windows, the value can also be shared within the machine and within the same user.
On Linux, in principle, you cannot share values between processes.
© 2024 OneMinuteCode. All rights reserved.