Cross-system dynamic library calling method and device, equipment and storage medium

By building a virtual running environment on the target terminal and using pythonnet library and virtual environment tools to call dynamic libraries between different operating systems, the problem of complex and inefficient dynamic library calls in the existing technology is solved, and efficient cross-system dynamic library calls are achieved.

CN119847611AActive Publication Date: 2025-04-18GUANGZHOU LEICHEN INTELLIGENT EQUIP TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410045098.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-11
Publication Date
2025-04-18
Estimated Expiration
2044-01-11

AI Technical Summary

Technical Problem

When calling dynamic libraries between different operating systems in the prior art, applications and transit programs need to be added, resulting in complex deployment and management and low work efficiency.

Method used

By building the running environment based on the pythonnet library and virtual environment tools on the target terminal, loading the target dynamic library under the second operating system, and calling the library interface according to the operation parameters in the virtual environment, cross-system dynamic library calls are realized.

Benefits of technology

It avoids system language conversion, reduces system language conversion time, shortens the working time of dynamic library calls, and improves the work efficiency of cross-system calls dynamic libraries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847611A_ABST
    Figure CN119847611A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a cross-system dynamic library calling method and device, equipment and a storage medium. The technical scheme provided by the embodiment of the invention is used for a target terminal, a first operating system runs in the target terminal, a target dynamic library is a library in a second operating system, and the method comprises the steps that a running environment is constructed on the target terminal based on the first operating system on the basis of a pythonnet library and a virtual environment tool, the pythonnet library is used for loading the target dynamic library in the second operating system, and the virtual environment tool is used for loading the target dynamic library in the second operating system. The virtual environment tool is used for providing a virtual environment for operation of the target dynamic library; obtaining a use document of the target dynamic library, and determining operation parameters corresponding to the target dynamic library according to the use document; and in the virtual environment tool, the pythonnet library calls the corresponding library interface in the target dynamic library according to the operation parameter to realize the function corresponding to the library interface, so that the problem of low working efficiency of cross-system calling of the dynamic library can be solved, and the working efficiency of cross-system calling of the dynamic library is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of dynamic library calling, and in particular, to a cross-system dynamic library calling method, apparatus, device and storage medium. Background Art

[0002] The operating system is the most basic and most important basic system software in the computer system. It is a collection of system software that manages computer hardware and software resources, controls the operation of other programs, and provides users with an interactive operation interface. It is responsible for basic tasks such as managing and configuring memory, controlling input and output devices, etc. Common operating systems include Windows, MacOS, Unix, Linux, and UOS.

[0003] Different computer operating systems are designed and implemented by different development teams, and different computer operating systems may have differences in architecture, interface and function. Such differences lead to incompatibility between different operating systems. When different computer operating systems need to call dynamic libraries, it is necessary to install corresponding transfer programs to convert the dynamic library of the first operating system into the dynamic library of the system language corresponding to the second operating system, so that the dynamic library can be used in the corresponding second operating system.

[0004] The existing method of implementing the call of dynamic libraries between different computer operating systems through a transfer program requires the addition of an application program and the dynamic library needs to be converted into the corresponding system language before it can be used, which increases the complexity of deployment and management and has relatively low work efficiency. Summary of the invention

[0005] The embodiments of the present application provide a cross-system dynamic library calling method, apparatus, device and storage medium, which can solve the problem of low working efficiency of cross-system dynamic library calling and improve the working efficiency of cross-system dynamic library calling.

[0006] In a first aspect, an embodiment of the present application provides a cross-system dynamic library calling method, which is used for a target terminal, where the target terminal runs a first operating system, and the target dynamic library is a library in a second operating system, including:

[0007] Building an operating environment based on the first operating system on the target terminal based on the pythonnet library and the virtual environment tool, the pythonnet library is used to load the target dynamic library under the second operating system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library;

[0008] Obtain the usage document of the target dynamic library, and determine the operating parameters corresponding to the target dynamic library according to the usage document;

[0009] In the virtual environment tool, the pythonnet library calls the corresponding library interface in the target dynamic library according to the running parameters to implement the corresponding functions of the library interface.

[0010] In a second aspect, an embodiment of the present application provides a cross-system dynamic library calling device, which is used for a target terminal, where the target terminal runs a first operating system, and the target dynamic library is a library in a second operating system, including:

[0011] An operating environment construction unit is used to construct an operating environment based on the first operating system on the target terminal based on a pythonnet library and a virtual environment tool, wherein the pythonnet library is used to load a target dynamic library under a second operating system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library;

[0012] An operation parameter determination unit, used to obtain a usage document of a target dynamic library, and determine operation parameters corresponding to the target dynamic library according to the usage document;

[0013] The calling unit is used in the virtual environment tool, and the pythonnet library calls the corresponding library interface in the target dynamic library according to the running parameters to implement the corresponding function of the library interface.

[0014] In a third aspect, an embodiment of the present application provides a cross-system dynamic library calling device, including:

[0015] memory and one or more processors;

[0016] A memory for storing one or more programs;

[0017] When one or more programs are executed by one or more processors, the one or more processors implement the cross-system dynamic library calling method of the first aspect.

[0018] In a fourth aspect, an embodiment of the present application provides a storage medium storing computer executable instructions, which, when executed by a computer processor, are used to execute the cross-system dynamic library calling method of the first aspect.

[0019] In the operation of the first operating system, the embodiment of the present application builds an operating environment on the target terminal based on the pythonnet library and the virtual environment tool, obtains the use document of the target dynamic library, determines the operating parameters corresponding to the target dynamic library according to the use document, and in the virtual environment tool, calls the library interface corresponding to the target dynamic library according to the operating parameters through the pythonnet library, and runs the corresponding target dynamic library in the first operating system based on the library interface to realize the function of the target dynamic library corresponding to the library interface. By adopting the above technical means, the library interface corresponding to the target dynamic library under the second operating system can be called in the virtual operating environment constructed by the first operating system, so as to avoid the problem of low work efficiency caused by the need to convert the system language in the process of calling the dynamic library across systems. In this embodiment, after the target dynamic library is loaded into the virtual environment tool according to the specified loading path in the first operating system, the library interface of the target dynamic library under the second operating system is directly called in the virtual environment tool based on the operating parameters, so as to run the corresponding target dynamic library in the first operating system, so that the function corresponding to the target dynamic library under the second operating system can be realized in the first operating system. Compared with the method of converting the system language in the prior art, the present embodiment does not need to convert the system language, which reduces the time of system language conversion, thereby shortening the working time of calling the target dynamic library, and thus improving the work efficiency of calling the dynamic library across systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a flow chart of a cross-system dynamic library calling method provided by an embodiment of the present application;

[0021] Figure 2 It is a structural diagram of a cross-system dynamic library calling device provided in an embodiment of the present application;

[0022] Figure 3 It is a structural diagram of a cross-system dynamic library calling device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.

[0024] Different computer operating systems are designed and implemented by different development teams, and different computer operating systems may have differences in architecture, interface and function. Such differences lead to incompatibility between different operating systems. When different computer operating systems need to call dynamic libraries, it is necessary to install corresponding transfer programs to convert the dynamic library of the first operating system into a dynamic library of the system language corresponding to the second operating system before the dynamic library can be used in the corresponding second operating system. The existing method of implementing the call of dynamic libraries between different computer operating systems through transfer programs requires the addition of application programs, and the dynamic libraries need to be converted into the corresponding system languages ​​before they can be used, which increases the complexity of deployment and management, and the work efficiency is relatively low. Based on this, the cross-system dynamic library calling method, device, equipment and storage medium provided by the present application are intended to be able to call the library interface corresponding to the target dynamic library under the second operating system in the virtual operating environment constructed by the first operating system when calling the dynamic library across systems, so as to avoid the problem of low work efficiency caused by the need to convert the system language during the cross-system dynamic library calling process. In this embodiment, after loading the target dynamic library into the virtual environment tool according to the specified loading path in the first operating system, the library interface of the target dynamic library under the second operating system is directly called in the virtual environment tool based on the running parameters, so as to run the corresponding target dynamic library in the first operating system, so that the corresponding function of the target dynamic library under the second operating system can be implemented in the first operating system. Compared with the prior art method of converting the system language, the present embodiment does not require the conversion of the system language, which reduces the time of system language conversion, thereby shortening the working time of the target dynamic library call, and thus improving the work efficiency of cross-system dynamic library calls.

[0025] Figure 1A flow chart of a cross-system dynamic library calling method provided in an embodiment of the present application is given. The cross-system dynamic library calling method provided in this embodiment can be executed by a cross-system dynamic library calling device, which can be implemented by software and / or hardware. The cross-system dynamic library calling device can be composed of two or more physical entities, or can be composed of one physical entity. Generally speaking, the cross-system dynamic library calling device can be a terminal device, such as a computer device, etc.

[0026] The following description is made by taking a computer device as an example of the subject of executing the cross-system dynamic library calling method. Figure 1 The cross-system dynamic library calling method is used for a target terminal, the target terminal runs a first operating system, and the target dynamic library is a library in a second operating system. The cross-system dynamic library calling method specifically includes:

[0027] S101. Building an operating environment based on a first operating system on a target terminal based on a pythonnet library and a virtual environment tool, wherein the pythonnet library is used to load a target dynamic library under a second operating system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library.

[0028] A dynamic library, also known as a shared library, is a library that is loaded at runtime, rather than linked at compile time. A dynamic library provides a way to expand and share code, which allows specific functions or features to be loaded and used when the program is running, rather than linking all the code at compile time. The system codes corresponding to the dynamic libraries of different operating systems are different. A first operating system, such as a Linux system, is running in the target terminal. Dynamic libraries of other systems (such as a second operating system, a Windows system) that can be pre-imported in the target terminal can call the corresponding dynamic libraries in subsequent use. During the operation of the first operating system, when it is necessary to call the dynamic library under the second operating system, it is necessary to pre-build an operating environment for calling the dynamic library across systems in order to perform a cross-system dynamic library call operation.

[0029] The target dynamic library is a dynamic library in the second operating system, the pythonnet library can be understood as a runtime library in the first operating system, which is used to load the target dynamic library under the second operating system, the first class library is used to process data and network communication, and the virtual environment tool is used to provide a virtual environment for the target dynamic library of the second operating system, for example, the virtual environment tool is a Mono framework. When building a runtime environment for calling a dynamic library across systems, the corresponding pythonnet library, the first class library and the virtual environment tool can be pre-installed in the target terminal, and the runtime environment can be built on the target terminal based on the first operating system based on the pythonnet library, the first class library and the virtual environment tool, and the corresponding cross-system target dynamic library can be called in the runtime environment later. The first operating system, such as the Linux system, is run in the target terminal, and the runtime environment is built based on the pre-installed pythonnet library, the first class library and the virtual environment tool. The dynamic library of the second operating system can be called in the virtual environment tool through the pythonnet library; the corresponding data processing and network communication can be performed in the virtual environment tool through the first class library. For example, when the first call instruction is received, the first class library is run according to the first call instruction to perform corresponding data processing and network communication in the virtual environment tool through the first class library. The first calling instruction is an instruction for triggering the calling of the first class library, and may be triggered by user input.

[0030] It should be noted that the first class library is compiled from codes. After the first class library is installed in the target terminal, the first class library can be run based on the first calling instruction to implement data processing and network communication functions corresponding to the first class library.

[0031] In one embodiment, in the first operating system, the pythonnet library can be imported into the Python code, and the functions, classes and modules in the pythonnet library can be used in the code later. In the first operating system, the first class library can be imported into the Python code, and the functions, classes and modules of the first class library can be used in the code later. In the above, the target terminal builds an operating environment based on the pre-installed runtime library, the first class library and the virtual environment tool, and provides a corresponding operating environment for the subsequent cross-system call dynamic library, so that the target dynamic library corresponding to the second operating system can be called without converting the system language. Compared with the prior art method of realizing cross-system calls by system language conversion, the time of system language conversion is reduced, thereby improving the work efficiency of cross-system call dynamic libraries.

[0032] In one embodiment, during the operation of the first operating system, when it is necessary to call a dynamic library, it is necessary to confirm the type of the dynamic library currently called to confirm whether the dynamic library currently called is the dynamic library of the first operating system itself or the dynamic library of another operating system (such as the second operating system) pre-imported. It should be noted that when the first system is running, when it is necessary to call a dynamic library under another system, the dynamic library under the other system can be pre-imported into the preset memory position of the target terminal for subsequent calling of the corresponding dynamic library from the preset memory position. During the operation of the first operating system, a dynamic library call instruction is received, and the type of the dynamic library currently called is determined according to the dynamic library call instruction. If the type of the dynamic library currently called is a dynamic library under the second operating system, that is, the target dynamic library in this embodiment, the subsequent S102 step is performed. Exemplarily, the extension name information of the dynamic library currently called is obtained according to the dynamic call instruction, and the type of the dynamic library currently called is determined according to the extension name information. If the extension name information contains a first mark, the type of the dynamic library currently called is determined to be a dynamic library under the first operating system; if the extension name information contains a second mark, the type of the dynamic library currently called is determined to be a dynamic library under the second operating system. For example, the extension information of the dynamic library under the Windows system contains ".dll", and the extension information of the dynamic library under the Linux system contains ".so". Assume that the first operating system is a Linux system, and the Linux system is running in the target terminal. When calling the dynamic library, the extension information of the dynamic library currently called is obtained according to the received dynamic library call instruction. If the extension information includes ".so", it is determined that the dynamic library currently called is the dynamic library of the Linux system itself; if the extension information includes ".dll", it is determined that the dynamic library currently called is the dynamic library under the Windows system. As described above, by confirming the type of the dynamic library currently called, different calling strategies corresponding to different types can be executed later, thereby improving the work efficiency of calling the dynamic library and reducing the probability of errors in the call operation.

[0033] S102: Obtain a usage document of the target dynamic library, and determine operating parameters corresponding to the target dynamic library according to the usage document.

[0034] The target dynamic library is a dynamic library under the second operating system, and the usage document of the dynamic library can be understood as a document that describes the usage methods, parameters and return values ​​of all functions under the target dynamic library, and provides instructions on sample code and error handling. When the first operating system is run on the target terminal, the target dynamic library under the second operating system can be pre-imported into the preset memory location of the target terminal. With the import of the target dynamic library, the usage document of the target dynamic library will be imported into the target terminal. When it is necessary to call the target dynamic library under the second operating system, the target terminal can obtain the usage document of the target dynamic library, and based on the analysis of the usage document, the operating parameters corresponding to the target dynamic library can be obtained, and the library interface call of the corresponding target dynamic library can be performed according to the operating parameters to implement the corresponding function of the target dynamic library.

[0035] Before calling the target dynamic library, in the aforementioned virtual environment tool (such as Mono framework), the loading path of the pre-imported target dynamic library is obtained through the pythonnet library. Wherein the target dynamic library is the dynamic library under the second operating system currently called, and the target dynamic library is pre-imported to the target terminal and stored in the preset memory location in the target terminal. The loading path can be understood as the path of the preset memory location of the corresponding target dynamic library. In the aforementioned virtual environment tool (such as Mono framework), the loading path of the pre-imported target dynamic library is obtained through the pythonnet library, and the target dynamic library is loaded into the virtual environment tool according to the loading path by the clr.AddReference function in the pythonnet library, so as to call the corresponding target dynamic library in the virtual environment tool later, and realize the corresponding function of the target dynamic library. After the target dynamic library is loaded into the virtual tool, based on the dynamic library is a library loaded at runtime, it is actually necessary to cooperate with the corresponding operating parameters to execute the corresponding library function, so the operating parameters corresponding to the target dynamic library can be determined according to the use document by obtaining the use document of the target dynamic library. For example, according to the usage document, it is determined that the required operating parameters of function A corresponding to the target dynamic library are 10 and 20. Subsequently, the corresponding library interface can be called according to the operating parameters 10 and 20 to implement function A.

[0036] It should be noted that the load path can be set to an absolute path or a relative path to indicate the location where the dynamic library is stored.

[0037] It should be noted that when the target dynamic library is loaded according to the loading path through the clr.AddReference function of the pythonnet library, if the loading fails, a loading failure prompt is sent to the display of the target terminal, so that the display can display the corresponding loading failure prompt.

[0038] As described above, the running parameters corresponding to the target dynamic library are obtained through the pythonnet library, which facilitates the subsequent calling of the library interface corresponding to the target dynamic library under the second operating system according to the running parameters in the virtual running environment constructed by the first operating system, so as to avoid the problem of low work efficiency caused by system language conversion. Compared with the existing method of converting the system language of the target dynamic library under the second operating system into the dynamic library under the first operating system before making a library call, this embodiment can load the target dynamic library into the virtual environment tool according to the specified loading path in the first operating system, and directly implement the function corresponding to the target dynamic library under the second operating system by calling the library interface using the running parameters under the virtual running tool in the first operating system. This embodiment does not require system language conversion, reduces the time of system language conversion, thereby shortening the working time of the target dynamic library call, and thus improving the work efficiency of cross-system dynamic library calls.

[0039] S103. In the virtual environment tool, the pythonnet library runs and calls the corresponding library interface in the target dynamic library according to the running parameters to implement the function corresponding to the library interface.

[0040] The library interface corresponding to the dynamic library refers to the set of functions or variables defined in the dynamic library, which can be used by other programs or libraries. The library interface defines the functions and behaviors provided by the dynamic library so that other programs or libraries can interact with it. In the aforementioned virtual environment tool (such as the Mono framework), the corresponding library interface in the target dynamic library is called according to the operating parameters through the pythonnet library to implement the corresponding function of the corresponding library interface based on the operating parameters. For example, according to the use document, the operating parameters required for function A corresponding to the target dynamic library are 10 and 20, and the corresponding library interface a (i.e., function a) can be called according to operating parameters 10 and operating parameters 20, and the program is executed based on operating parameters 10 and operating parameters 20 in conjunction with library interface a (i.e., function a) to implement function A. As described above, after the target dynamic library is loaded into the virtual environment tool according to the specified loading path in the first operating system, in the virtual environment tool, the pythonnet library runs and calls the corresponding library interface in the target dynamic library under the second operating system according to the running parameters, so as to run the corresponding target dynamic library in the first operating system, so that the corresponding functions of the target dynamic library under the second operating system can be implemented in the first operating system, and cross-system calls can be realized without converting the target dynamic library to the system language. Compared with the existing method of realizing cross-system dynamic library calls through system language conversion, the time and labor cost investment of system language conversion are reduced, thereby shortening the time of cross-system dynamic library calls, thereby improving the work efficiency of cross-system dynamic library calls and saving labor cost investment.

[0041] It should be noted that the target dynamic library includes at least one function. When the target dynamic library includes one function, in the virtual environment tool, the pythonnet library determines the corresponding operating parameters through the usage document corresponding to the target dynamic library, calls the corresponding library interface according to the operating parameters, and implements the corresponding function of the target dynamic library. When the target dynamic library includes multiple functions, in the virtual environment tool, the pythonnet library determines the corresponding operating parameters through the usage document corresponding to the target dynamic library, calls the corresponding library interface according to the operating parameters, and implements the corresponding functions of the target dynamic library in turn.

[0042] During the process of calling the target dynamic library, if there is an operation exception in the virtual environment tool, the try-except block in the pythonnet library is used to capture and repair the exception. By using the try-except block in the pythonnet library to capture and repair the exception, the target dynamic library can run normally in the virtual environment tool, reducing the probability of operation failure and improving the overall work efficiency of calling dynamic libraries across systems.

[0043] In one embodiment, the first operating system is a Linux system, the second operating system is a Windows system, and the virtual environment tool is a Mono framework. Among them, the pythonnet library is used to load the target dynamic library under the Windows system. Take the target dynamic library as a ".NET program" as an example for explanation. The Linux system is run in the target terminal, and the pythonnet library, the first class library and the Mono framework are pre-installed during the operation of the Linux system. The operating environment is constructed based on the pre-installed pythonnet library, the first class library and the Mono framework. The first class library is a class library for processing data and network communication when the ".NET program" is run in the Mono framework, for example, including other libraries for processing data and / or libraries for network communication. When the target terminal runs the first operating system, when it is necessary to call the target dynamic library under the second operating system, for example, the target dynamic library currently called is a ".NET program" under the Windows system, then the loading path of the pre-imported ".NET program" is obtained through the pythonnet library under the Mono framework, and the ".NET program" is loaded into the Mono framework according to the loading path through the clr.AddReference function of the pythonnet library. It should be noted that the ".NET program" under the Windows system is pre-imported into the preset memory location of the target terminal for storage. After loading, the usage document corresponding to the ".NET program" is obtained through the pythonnet library, and the corresponding operating parameters are determined according to the usage document corresponding to the ".NET program". The pythonnet library calls the library interface corresponding to the ".NET program" according to the operating parameters to implement the functions of the ".NET program". During the operation of the Mono framework, if there is an operating exception, the try-except block in the pythonnet library is used to capture and repair the exception to repair or eliminate the corresponding exception.

[0044] In one embodiment, when performing the abnormality repair process, a corresponding abnormality repair process strategy can be selected according to the specific abnormality type. After performing the abnormality repair process, operations such as printing abnormality elimination information, recording logs, and returning error codes can be performed to record abnormal situation information.

[0045] As mentioned above, in a target terminal running a Linux system, a target dynamic library (e.g., ".NET program") under a Windows system is imported. Then, in the above manner, in the target terminal running a Linux system, after the target dynamic library (e.g., ".NET program") is loaded into the Mono framework according to the specified loading path in the first operating system through the pythonnet library, the library interface corresponding to the target dynamic library (e.g., ".NET program") under the Windows system is called in the Mono framework, so as to run the corresponding target dynamic library (e.g., ".NET program") in the first operating system, so that the target dynamic library under the second operating system can be implemented in the first operating system. Compared with the existing need to add an additional terminal device running the Windows system or add additional system language translation software, in this embodiment, after the target dynamic library (such as the ".NET program") is loaded into the Mono framework according to the specified loading path through the pythonnet library in the first operating system, the cross-system dynamic library call is directly implemented in the Mono framework through the library interface call, and there is no need to convert the system language, which saves the cost of additional equipment or software and the time of system language translation, thereby shortening the time of cross-system dynamic library calls and improving the work efficiency of cross-system dynamic library calls.

[0046] In the above, in the operation of the first operating system, an operating environment is constructed on the target terminal based on the pythonnet library and the virtual environment tool, the use document of the target dynamic library is obtained, and the operating parameters corresponding to the target dynamic library are determined according to the use document. In the virtual environment tool, the library interface corresponding to the target dynamic library is called according to the operating parameters through the pythonnet library, and the corresponding target dynamic library is run in the first operating system based on the library interface to realize the function of the target dynamic library corresponding to the library interface. By adopting the above technical means, the library interface corresponding to the target dynamic library under the second operating system can be called in the virtual operating environment constructed by the first operating system, so as to avoid the problem of low work efficiency caused by the need to convert the system language during the cross-system call dynamic library process. In this embodiment, after the target dynamic library is loaded into the virtual environment tool according to the specified loading path in the first operating system, the library interface of the target dynamic library under the second operating system is directly called in the virtual environment tool based on the operating parameters, so as to run the corresponding target dynamic library in the first operating system, so that the function corresponding to the target dynamic library under the second operating system can be realized in the first operating system. Compared with the prior art by converting the system language, this embodiment does not need to convert the system language, which reduces the time of system language conversion, thereby shortening the working time of the target dynamic library call, and thus improving the work efficiency of the cross-system call dynamic library.

[0047] Based on the above embodiments, Figure 2 A schematic diagram of the structure of a cross-system dynamic library calling device provided in an embodiment of the present application. Figure 2 The cross-system dynamic library calling device provided in this embodiment is used for a target terminal, the target terminal runs a first operating system, and the target dynamic library is a library in a second operating system, including an operating environment building unit 21, an operating parameter determining unit 22 and a calling unit 23;

[0048] The operating environment construction unit 21 is used to construct an operating environment based on the first operating system on the target terminal based on the pythonnet library and the virtual environment tool, the pythonnet library is used to load the target dynamic library under the second operating system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library;

[0049] An operation parameter determination unit 22 is used to obtain a usage document of a target dynamic library and determine operation parameters corresponding to the target dynamic library according to the usage document;

[0050] The calling unit 23 is used for the pythonnet library to call the corresponding library interface in the target dynamic library according to the running parameters in the virtual environment tool to implement the function corresponding to the library interface.

[0051] In one embodiment, the device further includes a path acquisition unit and a loading unit;

[0052] A path acquisition unit is used to obtain the loading path of the pre-imported target dynamic library through the pythonnet library in the virtual environment tool;

[0053] The loading unit is used to load the target dynamic library into the virtual environment tool according to the loading path through the pythonnet library.

[0054] In one embodiment, the operating environment construction unit 21 includes an installation subunit, an environment construction subunit and a first operating subunit;

[0055] An installation subunit is used to install a first class library, a pythonnet library and a virtual environment tool on a target terminal, wherein the first class library is used to process data and network communication;

[0056] An environment construction subunit is used to construct an operating environment based on the first operating system on the target terminal based on the pythonnet library, the first class library and the virtual environment tool;

[0057] The first running subunit is used to receive a first calling instruction and run a first class library according to the first calling instruction, so as to perform corresponding data processing and network communication in a virtual environment tool through the first class library.

[0058] In one embodiment, the first operating system is a Linux system, and the second operating system is a Windows system;

[0059] The operating environment construction unit 21 includes a second operating subunit;

[0060] The second running subunit is used to run the Linux system in the target terminal;

[0061] The environment construction subunit is used to build the operating environment based on the pythonnet library and the virtual environment tool during the operation of the Linux system. The pythonnet library is used to load the target dynamic library under the Windows system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library.

[0062] In one embodiment, the loading unit is further used to load the target dynamic library into the virtual environment tool through the clr.AddReference function in the pythonnet library in the virtual environment tool.

[0063] In one embodiment, the apparatus further comprises an anomaly repair unit;

[0064] The exception repair unit is used to capture and repair exceptions through the try-except block in the pythonnet library if there are running exceptions in the virtual environment tool.

[0065] In one embodiment, the apparatus further comprises a call type confirmation subunit;

[0066] A call type confirmation subunit is used to receive a dynamic library call instruction and confirm the type of the dynamic library currently called according to the dynamic library call instruction;

[0067] The operation parameter determination unit 22 is further configured to obtain a usage document of the target dynamic library if the type is a dynamic library under the second operating system.

[0068] In the above, in the operation of the first operating system, an operating environment is constructed on the target terminal based on the pythonnet library and the virtual environment tool, the use document of the target dynamic library is obtained, and the operating parameters corresponding to the target dynamic library are determined according to the use document. In the virtual environment tool, the library interface corresponding to the target dynamic library is called according to the operating parameters through the pythonnet library, and the corresponding target dynamic library is run in the first operating system based on the library interface to realize the function of the target dynamic library corresponding to the library interface. By adopting the above technical means, the library interface corresponding to the target dynamic library under the second operating system can be called in the virtual operating environment constructed by the first operating system, so as to avoid the problem of low work efficiency caused by the need to convert the system language during the cross-system call dynamic library process. In this embodiment, after the target dynamic library is loaded into the virtual environment tool according to the specified loading path in the first operating system, the library interface of the target dynamic library under the second operating system is directly called in the virtual environment tool based on the operating parameters, so as to run the corresponding target dynamic library in the first operating system, so that the function corresponding to the target dynamic library under the second operating system can be realized in the first operating system. Compared with the prior art by converting the system language, this embodiment does not need to convert the system language, which reduces the time of system language conversion, thereby shortening the working time of the target dynamic library call, and thus improving the work efficiency of the cross-system call dynamic library.

[0069] The cross-system dynamic library calling device provided in the embodiment of the present application can be used to execute the cross-system dynamic library calling method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0070] The present application embodiment provides a cross-system dynamic library calling device, referring to Figure 3 The cross-system dynamic library calling device includes: a processor 31, a memory 32, a communication module 33, an input device 34 and an output device 35. The number of processors in the cross-system dynamic library calling device can be one or more, and the number of memories in the cross-system dynamic library calling device can be one or more. The processor, memory, communication module, input device and output device of the cross-system dynamic library calling device can be connected through a bus or other methods.

[0071] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as the program instructions / modules corresponding to the cross-system dynamic library calling method described in any embodiment of the present application (for example, the operating environment construction unit, the operating parameter determination unit and the calling unit in the cross-system dynamic library calling device). The memory may mainly include a storage program area and a storage data area, wherein the storage program area can store an operating system, an application required for at least one function; the storage data area can store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device or other non-volatile solid-state storage device. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0072] The communication module 33 is used for data transmission.

[0073] The processor 31 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory, that is, implements the above-mentioned cross-system dynamic library calling method.

[0074] The input device 34 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 35 may include a display device such as a display screen.

[0075] The cross-system dynamic library calling device provided above can be used to execute the cross-system dynamic library calling method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0076] The embodiment of the present application also provides a storage medium storing computer executable instructions, which are used to execute a cross-system dynamic library calling method when executed by a computer processor. The cross-system dynamic library calling method is used for a target terminal, and the target terminal runs a first operating system. The target dynamic library is a library in a second operating system, including: building an operating environment based on the first operating system on the target terminal based on a pythonnet library and a virtual environment tool, the pythonnet library is used to load the target dynamic library under the second operating system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library; obtaining a usage document of the target dynamic library, and determining the operating parameters corresponding to the target dynamic library according to the usage document; in the virtual environment tool, the pythonnet library calls the corresponding library interface in the target dynamic library according to the operating parameters to implement the functions corresponding to the library interface.

[0077] Storage medium - any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the first computer system in which the program is executed, or may be located in a different second computer system, which is connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media residing in different locations (for example, in different computer systems connected by a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.

[0078] Of course, the computer executable instructions of a storage medium storing computer executable instructions provided in an embodiment of the present application are not limited to the above cross-system dynamic library calling method, and can also execute related operations in the cross-system dynamic library calling method provided in any embodiment of the present application.

[0079] The cross-system dynamic library calling device, storage medium and cross-system dynamic library calling equipment provided in the above embodiments can execute the cross-system dynamic library calling method provided in any embodiment of the present application. For technical details not described in detail in the above embodiments, please refer to the cross-system dynamic library calling method provided in any embodiment of the present application.

[0080] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the protection scope of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.

Claims

1. A cross-system dynamic library calling method, characterized in that: For a target terminal, the target terminal runs a first operating system, and the target dynamic library is a library in a second operating system, including: Building an operating environment based on the first operating system on a target terminal based on a pythonnet library and a virtual environment tool, wherein the pythonnet library is used to load a target dynamic library under the second operating system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library; Obtaining a usage document of the target dynamic library, and determining an operating parameter corresponding to the target dynamic library according to the usage document; In the virtual environment tool, the pythonnet library calls the corresponding library interface in the target dynamic library according to the running parameters to implement the function corresponding to the library interface.

2. The method according to claim 1, characterized in that In the virtual environment tool, before the pythonnet library calls the corresponding library interface in the target dynamic library according to the running parameters, it also includes: In the virtual environment tool, obtaining the loading path of the pre-imported target dynamic library through the pythonnet library; The target dynamic library is loaded into the virtual environment tool according to the loading path through the pythonnet library.

3. The method according to claim 1, characterized in that The step of constructing an operating environment based on the first operating system on the target terminal based on the pythonnet library and the virtual environment tool includes: Installing a first class library, a pythonnet library and a virtual environment tool on the target terminal, wherein the first class library is used for processing data and network communication; Building an operating environment based on the first operating system on a target terminal based on the pythonnet library, the first class library and the virtual environment tool; A first calling instruction is received, and the first class library is run according to the first calling instruction, so as to perform corresponding data processing and network communication in the virtual environment tool through the first class library.

4. The method according to claim 1, characterized in that The first operating system is a Linux system, and the second operating system is a Windows system; The step of constructing an operating environment based on the first operating system on the target terminal based on the pythonnet library and the virtual environment tool includes: Running the Linux system in the target terminal; During the operation of the Linux system, an operating environment is constructed based on the pythonnet library and a virtual environment tool. The pythonnet library is used to load a target dynamic library under the Windows system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library.

5. The method according to claim 2, characterized in that: In the virtual environment tool, loading the target dynamic library into the virtual environment tool according to the loading path through the pythonnet library includes: In the virtual environment tool, the target dynamic library is loaded into the virtual environment tool through the clr.AddReference function in the pythonnet library.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: If there is an operational exception in the virtual environment tool, the exception is captured and repaired through the try-except block in the pythonnet library.

7. The method according to claim 1, characterized in that Before obtaining the usage document of the target dynamic library, the method includes: Receiving a dynamic library calling instruction, and confirming the type of the dynamic library currently called according to the dynamic library calling instruction; If the type is a dynamic library under the second operating system, the usage document of the target dynamic library is obtained.

8. A cross-system dynamic library calling device, characterized in that: For a target terminal, the target terminal runs a first operating system, and the target dynamic library is a library in a second operating system, including: An operating environment construction unit, configured to construct an operating environment based on the first operating system on a target terminal based on a pythonnet library and a virtual environment tool, wherein the pythonnet library is used to load a target dynamic library under the second operating system, and the virtual environment tool is used to provide a virtual environment for the operation of the target dynamic library; An operation parameter determination unit, used for obtaining a usage document of the target dynamic library, and determining an operation parameter corresponding to the target dynamic library according to the usage document; The calling unit is used for, in the virtual environment tool, the pythonnet library calling the corresponding library interface in the target dynamic library according to the running parameters to implement the function corresponding to the library interface.

9. A cross-system dynamic library calling device, characterized in that: include: memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A storage medium storing computer executable instructions, characterized in that: The computer executable instructions are used to perform the method according to any one of claims 1 to 7 when executed by a processor.

Citation Information

Patent Citations

  • Method and device for running second system application in first system, equipment and medium

    CN111984263A

  • Linux application libc library calling method, system and device and storage medium

    CN113672412A

  • Python and Fortran intermodulation method, system and device and storage medium

    CN117170738A

  • Portable virtual applications

    US20120246634A1

  • File system service for virtualized graphics processing units

    US9875192B1