It is recommended to refer to Inter-Process Communication (RPC)
However, it may not be possible to directly include the header file of the background program and use the functions of the background program
The program started in the background is a service (a memory-resident process, A), and the subsequent program (called program B) and A can communicate in various ways;
After being able to communicate, all functions in A can be called at will (of course, through the protocol negotiated by both parties);
If you need to directly expose a function to the outside world, in fact, you need to publish this function as a service for other users to use;
Publish functions into services. Some middleware services do this, such as Tuxedo;
There are many ways to communicate between processes,
For example, pipes; shared memory, queues, etc.; refer to "UNIX Network Programming Volume 2" inter-process communication: http://www.me115.com/book/129.html
Perhaps your requirement is just a dynamic link library to package A's code into a dynamic library,
Expose the header file interface for B to use? In this way, there is only one process;
It is recommended to refer to Inter-Process Communication (RPC)
However, it may not be possible to directly include the header file of the background program and use the functions of the background program
The simplest way is to redirect the standard input and standard output and control the background program through them.
http://stackoverflow.com/questions/2680174/redirect-stdin-in-c-program-to-another-process
The program started in the background is a service (a memory-resident process, A), and the subsequent program (called program B) and A can communicate in various ways;
After being able to communicate, all functions in A can be called at will (of course, through the protocol negotiated by both parties);
If you need to directly expose a function to the outside world, in fact, you need to publish this function as a service for other users to use;
Publish functions into services. Some middleware services do this, such as Tuxedo;
There are many ways to communicate between processes,
For example, pipes; shared memory, queues, etc.; refer to "UNIX Network Programming Volume 2" inter-process communication: http://www.me115.com/book/129.html
Perhaps your requirement is just a dynamic link library to package A's code into a dynamic library,
Expose the header file interface for B to use? In this way, there is only one process;
Extract the parts shared by the current background program and other programs into a dynamic library
webService,soap