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

By building a virtual runtime environment on the first operating system, and using the pythonnet library and virtual environment tools to load and call the dynamic libraries of the second operating system, the problem of low efficiency in dynamic library calls between different operating systems is solved, and efficient cross-system dynamic library calls are achieved.

CN119847611BActive Publication Date: 2025-12-12GUANGZHOU LEICHEN INTELLIGENT EQUIP TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Calling dynamic libraries between different operating systems requires a relay program to perform system language conversion, resulting in low work efficiency and complex management.

Method used

By building a virtual runtime environment on the first operating system, using the pythonnet library and virtual environment tools to load the dynamic libraries of the second operating system, and determining the running parameters according to the user documentation, the library interfaces are directly called in the virtual environment, avoiding system language conversion.

Benefits of technology

It improves the efficiency of cross-system calls to dynamic libraries, reduces system language conversion time, shortens call time, and reduces labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847611B_ABST
    Figure CN119847611B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a cross-system dynamic library calling method and device, equipment and a storage medium. The technical scheme provided by the embodiments of the present application is used for a target terminal, the target terminal runs a first operating system, a target dynamic library is a library in a second operating system, and the method comprises the following steps: based on a pythonnet library and a virtual environment tool, a running environment is constructed on the target terminal based on the first operating system, 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 running of the target dynamic library; a usage document of the target dynamic library is acquired, and running parameters corresponding to the target dynamic library are determined according to the usage document; in the virtual environment tool, the pythonnet library calls a corresponding library interface in the target dynamic library according to the running parameters, so as to realize the functions corresponding to the library interface, and the problem of low work efficiency of cross-system calling of the dynamic library can be solved, and the work 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] 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, device, equipment and storage medium. BACKGROUND

[0002] An operating system is the most basic and most important basic system software in a computer system, is a collection of system software for managing computer hardware and software resources, controlling the running of other programs and providing an interactive operation interface for users, is responsible for basic tasks such as managing and configuring memory, controlling input and output devices, etc. Common operating systems include Windows system, Mac OS system, Unix system, Linux system and UOS system, etc.

[0003] Different computer operating systems are designed and implemented by different development teams based on different computer operating systems, and different computer operating systems may differ in architecture, interface and function. Such differences lead to incompatibility between different operating systems. When different computer operating systems need to call a dynamic library, a corresponding transfer program needs to be installed to convert the dynamic library of the first operating system into a dynamic library of the corresponding system language of the second operating system, so that the dynamic library can be used in the corresponding second operating system.

[0004] The existing way of calling a dynamic library between different computer operating systems through a transfer program needs to increase an application program, and needs to be converted into a dynamic library of the corresponding system language to be used, which increases the complexity of deployment and management, and the work efficiency is relatively low. SUMMARY

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

[0006] In a first aspect, embodiments of the present application provide a cross-system dynamic library calling method for a target terminal, the target terminal running a first operating system, and a target dynamic library being a library in a second operating system, comprising:

[0007] Based on the first operating system, a running environment is constructed 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 running of the target dynamic library;

[0008] A usage document of the target dynamic library is obtained, and running parameters corresponding to the target dynamic library are determined according to the usage document;

[0009] In the virtual environment tool, the pythonnet library calls a corresponding library interface in the target dynamic library according to the running parameter, so as to realize the function corresponding to the library interface.

[0010] In a second aspect, the embodiments of the present application provide a cross-system dynamic library calling apparatus, for a target terminal, the target terminal running a first operating system, the target dynamic library being a library in a second operating system, comprising:

[0011] A running environment construction unit is configured to construct a running environment on the target terminal based on the first operating system based on the pythonnet library and the virtual environment tool, the pythonnet library being configured to load the target dynamic library under the second operating system, and the virtual environment tool being configured to provide a virtual environment for running of the target dynamic library;

[0012] A running parameter determination unit is configured to acquire a usage document of the target dynamic library, and determine a running parameter corresponding to the target dynamic library according to the usage document;

[0013] A calling unit is configured to, in the virtual environment tool, call a corresponding library interface in the target dynamic library by the pythonnet library according to the running parameter, so as to realize a function corresponding to the library interface.

[0014] In a third aspect, the embodiments of the present application provide a cross-system dynamic library calling device, comprising:

[0015] a memory and one or more processors;

[0016] The memory is configured to store one or more programs;

[0017] When the one or more programs are executed by the 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, the embodiments of the present application provide a storage medium storing computer executable instructions, which, when executed by a computer processor, are configured to perform the cross-system dynamic library calling method of the first aspect.

[0019] In the running of the first operating system, the embodiment of the present application constructs a running environment on the target terminal based on the pythonnet library and the virtual environment tool, obtains the usage document of the target dynamic library, determines the running parameters corresponding to the target dynamic library according to the usage document, and in the virtual environment tool, calls the library interface corresponding to the target dynamic library according to the running parameters based on the pythonnet library, and runs the corresponding target dynamic library in the first operating system based on the library interface, so as to realize the function of the target dynamic library corresponding to the library interface. By using the above technical means, the library interface corresponding to the target dynamic library under the second operating system can be called in the virtual running environment constructed in the first operating system, so that the problem of low work efficiency caused by the conversion of system language in the process of cross-system calling of the dynamic library can be avoided. In the embodiment, the target dynamic library can be loaded into the virtual environment tool according to the specified loading path in the first operating system, and the library interface of the target dynamic library under the second operating system can be directly called in the virtual environment tool based on the running parameters, so that the corresponding target dynamic library can be run 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, the embodiment does not need to convert the system language, reduces the time of system language conversion, shortens the working time of the target dynamic library calling, and further improves the work efficiency of cross-system calling of the dynamic library. BRIEF DESCRIPTION OF DRAWINGS

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

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

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

[0023] In order to make the purposes, technical solutions and advantages of the present application clearer, the following further describes specific embodiments of the present application in conjunction with the accompanying drawings. It can be understood that the specific embodiments described herein are merely used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the convenience of description, only parts related to the present application are shown in the drawings, but not all. Before discussing the example embodiments in more detail, it should be mentioned that some example embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The processes can be terminated when the operations are completed, but can also have additional steps not included in the drawings. The processes can correspond to methods, functions, procedures, subroutines, etc.

[0024] Different computer operating systems are designed and implemented by different development teams based on different computer operating systems, and different computer operating systems can have differences in architecture, interface and function. Such differences result in incompatibility between different operating systems. When different computer operating systems need to call dynamic libraries, a corresponding relay program needs to be installed to convert the dynamic library of the first operating system into a dynamic library of the corresponding system language of the second operating system, so that the dynamic library can be used in the corresponding second operating system. The existing way of realizing the calling of dynamic libraries between different computer operating systems through the relay program needs to increase the application program, and needs to be converted into a dynamic library of the corresponding system language to 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 aims to call a dynamic library across systems, which can call the library interface corresponding to the target dynamic library under the second operating system in the virtual running environment constructed in the first operating system. In this way, the problem of low work efficiency caused by the conversion of system language in the process of calling the dynamic library across systems can be avoided. The embodiment can load the target dynamic library to the virtual environment tool according to the specified loading path in the first operating system, and then directly call the library interface of the target dynamic library under the second operating system based on the running parameters in the virtual environment tool. In this way, the corresponding target dynamic library is run 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, 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 the target dynamic library calling, and further improving the work efficiency of calling the dynamic library across systems.

[0025] Figure 1A flowchart 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 the embodiment can be executed by a cross-system dynamic library calling device. The cross-system dynamic library calling device can be implemented in software and / or hardware. The cross-system dynamic library calling device can be composed of two or more physical entities, or one physical entity. Generally, the cross-system dynamic library calling device can be a terminal device, such as a computer device.

[0026] The following describes a computer device as an example of a subject executing a cross-system dynamic library calling method. Referring to Figure 1 The cross-system dynamic library calling method is used for a target terminal. The target terminal runs a first operating system. A target dynamic library is a library in a second operating system. The cross-system dynamic library calling method specifically includes the following steps.

[0027] In S101, a running environment is constructed on the target terminal based on the first operating system 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. The virtual environment tool is used to provide a virtual environment for running the target dynamic library.

[0028] A dynamic library is also called a shared library. It is a library loaded at runtime, rather than a library linked at compile time. A dynamic library provides a way to extend and share code. It allows specific functions or features to be loaded and used at runtime, rather than linking all the code at compile time. The system code corresponding to the dynamic library of different operating systems is different. The target terminal runs a first operating system, for example, a Linux system. The dynamic library of another system (for example, a second operating system, a Windows system) can be pre-imported in the target terminal. In subsequent use, the corresponding dynamic library can be called. During the running of the first operating system, when the dynamic library under the second operating system needs to be called, the running environment of the cross-system dynamic library calling needs to be constructed in advance, so that the cross-system dynamic library calling operation can be performed.

[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, and is used to load the target dynamic library under the second operating system. The first type of library is used to process data and network communication. 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 type of library and the virtual environment tool can be pre-installed in the target terminal. Based on the pythonnet library, the first type of library and the virtual environment tool, a runtime environment is built on the target terminal based on the first operating system. Subsequently, the corresponding cross-system target dynamic library can be called in the runtime environment. The first operating system, for example, a Linux system, is run in the target terminal. Based on the pre-installed pythonnet library, the first type of library and the virtual environment tool, a runtime environment is built. In the virtual environment tool, the dynamic library of the second operating system can be called through the pythonnet library. In the virtual environment tool, the corresponding data processing and network communication can be performed through the first type of library. For example, when a first calling instruction is received, the first type of library is run according to the first calling instruction, so that the corresponding data processing and network communication in the virtual environment tool are performed through the first type of library. The first calling instruction is an instruction for triggering the calling of the first type of library, which can be triggered by a user.

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

[0031] In an embodiment, in the first operating system, the pythonnet library can be imported in the Python code. Subsequently, the functions, classes and modules in the pythonnet library can be used in the code. In the first operating system, the first type of library can be imported in the Python code. Subsequently, the functions, classes and modules of the first type of library can be used in the code. Through the target terminal, the runtime environment is built based on the pre-installed runtime library, the first type of library and the virtual environment tool, which provides a corresponding runtime environment for subsequent cross-system calling of a dynamic library, so that the target dynamic library of the corresponding second operating system can be called without system language conversion. Compared with the prior art, the time for system language conversion is reduced, thereby improving the working efficiency of cross-system calling of a dynamic library.

[0032] In an embodiment, during the running of the first operating system, when a dynamic library needs to be called, the type of the currently called dynamic library needs to be confirmed to confirm whether the currently called dynamic library is a dynamic library of the first operating system itself or a dynamic library of another operating system (for example, the second operating system) which is pre-imported. It needs to be noted that when a dynamic library under another system needs to be called during the running of the first system, the dynamic library under the other system can be pre-imported into a preset memory location of the target terminal to be called from the preset memory location in the subsequent process. During the running of the first operating system, a dynamic library calling instruction is received, the type of the currently called dynamic library is determined according to the dynamic library calling instruction, if the type of the currently called dynamic library is a dynamic library under the second operating system, that is, the target dynamic library in the embodiment, the subsequent step S102 is performed. For example, the extension information of the currently called dynamic library is obtained according to the dynamic calling instruction, and the type of the currently called dynamic library is determined according to the extension information. If the first mark is included in the extension information, it is determined that the type of the currently called dynamic library is a dynamic library under the first operating system; if the second mark is included in the extension information, it is determined that the type of the currently called dynamic library is a dynamic library under the second operating system. For example, the extension information of the dynamic library under the Windows system includes “.dll”, and the extension information of the dynamic library under the Linux system includes “.so”. Assuming that the first operating system is the Linux system, the Linux system is run in the target terminal, when a dynamic library is called, the extension information of the currently called dynamic library is obtained according to the received dynamic library calling instruction, if the “.so” is included in the extension information, it is determined that the currently called dynamic library is a dynamic library of the Linux system itself; if the “.dll” is included in the extension information, it is determined that the currently called dynamic library is a dynamic library under the Windows system. Through the above, the type of the currently called dynamic library is confirmed, and the corresponding calling strategy can be executed according to different types in the subsequent process, so as to improve the working efficiency of calling the dynamic library and reduce the probability of calling and running errors.

[0033] S102, obtain the usage document of the target dynamic library, and determine the running parameter 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 describing the usage method, parameters and return value of all functions under the target dynamic library, and providing instructions in aspects such as example code and error processing. When the first operating system is running on the target terminal, the target dynamic library under the second operating system can be pre-imported into a preset memory location of the target terminal. With the import of the target dynamic library, the usage document of the target dynamic library is imported into the target terminal. When the target dynamic library under the second operating system needs to be called, the target terminal can obtain the usage document of the target dynamic library, and can obtain the running parameters corresponding to the target dynamic library based on the analysis of the usage document. Subsequently, the library interface of the corresponding target dynamic library can be called according to the running parameters to realize the function corresponding to the target dynamic library.

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

[0036] It should be noted that the loading path can be set as an absolute path or a relative path, which is used to indicate the storage location of the dynamic library.

[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 for displaying the corresponding loading failure prompt.

[0038] According to the above, the running parameters corresponding to the target dynamic library are obtained through the pythonnet library, so as to facilitate subsequent calling of the library interface corresponding to the target dynamic library under the second operating system in the virtual running environment constructed in the first operating system according to the running parameters, thereby avoiding the problem of low work efficiency caused by system language conversion. Compared with the existing method of converting the target dynamic library under the second operating system into a dynamic library under the first operating system through system language conversion to realize library calling, the embodiment can load the target dynamic library into the virtual environment tool according to the specified loading path in the first operating system, and then directly realize the function corresponding to the target dynamic library under the second operating system through the library interface calling mode using the running parameters in the virtual running tool in the first operating system. The embodiment does not need to perform system language conversion, reduces the system language conversion time, thereby shortens the work time of target dynamic library calling, and further improves the work efficiency of cross-system dynamic library calling.

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

[0040] The library interface corresponding to the dynamic library refers to a 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 foregoing virtual environment tool (such as the Mono framework), the pythonnet library calls the corresponding library interface in the target dynamic library according to the running parameters to realize the function corresponding to the library interface based on the running parameters. For example, according to the use document, the running parameters required for function A corresponding to the target dynamic library are 10 and 20, the corresponding library interface a (i.e. function a) can be called according to the running parameter 10 and the running parameter 20, and the program is executed based on the running parameter 10 and the running parameter 20 in cooperation with the library interface a (i.e. function a) to realize function A. According to the above, after loading the target dynamic library into the virtual environment tool according to the specified loading path in the first operating system, the pythonnet library calls the corresponding library interface in the target dynamic library under the second operating system according to the running parameters in the virtual environment tool, so that the corresponding target dynamic library can be run 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, and the target dynamic library can be cross-system called without system language conversion. Compared with the existing method of realizing cross-system dynamic library calling through system language conversion, the time and labor cost of system language conversion are reduced, thereby the time of cross-system dynamic library calling is shortened, and the work efficiency of cross-system dynamic library calling is improved, and the labor cost is saved.

[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 running parameters through the use document corresponding to the target dynamic library, calls the corresponding library interface according to the running parameters, and realizes the function corresponding to the target dynamic library. When the target dynamic library includes multiple functions, in the virtual environment tool, the pythonnet library determines the corresponding running parameters through the use document corresponding to the target dynamic library, calls the corresponding library interface according to the running parameters, and realizes the functions corresponding to the target dynamic library in turn.

[0042] In the process of calling the target dynamic library, if there is a running exception in the virtual environment tool, the exception capture and exception repair processing are performed through the try-except block in the pythonnet library. Through the try-except block in the pythonnet library, the exception capture and exception repair processing are performed, so that the target dynamic library can normally run in the virtual environment tool, the probability of running failure is reduced, and the overall working efficiency of the cross-system calling dynamic library is improved.

[0043] In an 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. The pythonnet library is used to load the target dynamic library under the Windows system. Taking a ".NET program" as an example, the Linux system is run in the target terminal. During the running of the Linux system, the pythonnet library, the first type of library, and the Mono framework are pre-installed. A running environment is built based on the pre-installed pythonnet library, the first type of library, and the Mono framework. The first type of library is a type of library used 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 dynamic library under the second operating system needs to be called when the first operating system is run in the target terminal, for example, the currently called target dynamic library is a ".NET program" under the Windows system, the loading path of the pre-imported ".NET program" is obtained in the Mono framework through the pythonnet library, 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 a preset memory location of the target terminal. After loading is completed, the use document corresponding to the ".NET program" is obtained through the pythonnet library, and the corresponding running parameters are determined according to the use document corresponding to the ".NET program". The library interface corresponding to the ".NET program" is called according to the running parameters through the pythonnet library, so as to realize the function of the ".NET program". During the running of the Mono framework, if there is an abnormality, the try-except block in the pythonnet library is used for exception capture and exception repair processing, so as to repair or eliminate the corresponding exception.

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

[0045] The above, in the target terminal running the Linux system, import a target dynamic library (for example, ".NET program") under the Windows system, and then the target dynamic library (for example, ".NET program") can be loaded into the Mono framework in the first operating system through the pythonnet library according to the specified loading path, and the library interface corresponding to the target dynamic library (for example, ".NET program") under the Windows system is called in the Mono framework, so that the corresponding target dynamic library (for example, ".NET program") is run in the first operating system, so that the function corresponding to the target dynamic library (for example, ".NET program") under the second operating system can be realized in the first operating system. Compared with the prior art, an additional terminal device running the Windows system or additional system language translation software is not needed, the library interface is called in the Mono framework after the target dynamic library (for example, ".NET program") is loaded into the Mono framework in the first operating system through the pythonnet library according to the specified loading path, the cross-system dynamic library calling is directly realized, the system language conversion is not needed, the cost of additional equipment or software is saved, the system language translation time is saved, the cross-system dynamic library calling time is shortened, and the work efficiency of cross-system dynamic library calling is improved.

[0046] The above, in the running of the first operating system, a virtual running 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, the running parameter corresponding to the target dynamic library is determined according to the use document, the library interface corresponding to the target dynamic library is called in the virtual environment tool through the pythonnet library according to the running parameter, and the function of the target dynamic library corresponding to the library interface is realized in the first operating system. By using the above technical means, the library interface corresponding to the target dynamic library under the second operating system can be called in the virtual running environment constructed in the first operating system, so that the problem of low work efficiency caused by system language conversion in the process of cross-system dynamic library calling can be avoided. In the embodiment, the library interface of the target dynamic library under the second operating system can be called in the virtual environment tool based on the running parameter after the target dynamic library is loaded into the virtual environment tool in the first operating system according to the specified loading path, so that the corresponding target dynamic library can be run in the first operating system. 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, the system language conversion is not needed, the system language conversion time is reduced, the target dynamic library calling time is shortened, and the work efficiency of cross-system dynamic library calling is improved.

[0047] On the basis of the above embodiments, Figure 2 A structural schematic diagram of a cross-system dynamic library calling device provided by the embodiment of the application is shown in FIG. 1. Figure 2 The cross-system dynamic library calling device provided by the embodiment of the application is used for a target terminal, the target terminal runs a first operating system, the target dynamic library is a library in a second operating system, and the device comprises a running environment construction unit 21, a running parameter determination unit 22 and a calling unit 23.

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

[0049] The running parameter determination unit 22 is configured to obtain a usage document of the target dynamic library and determine running parameters corresponding to the target dynamic library according to the usage document.

[0050] The calling unit 23 is configured to call a corresponding library interface in the target dynamic library according to the running parameters by the pythonnet library in the virtual environment tool, so as to realize a function corresponding to the library interface.

[0051] In an embodiment, the device further comprises a path obtaining unit and a loading unit.

[0052] The path obtaining unit is configured to obtain a loading path of the target dynamic library pre-imported by the pythonnet library in the virtual environment tool.

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

[0054] In an embodiment, the running environment construction unit 21 comprises an installation subunit, an environment construction subunit and a first running subunit.

[0055] The installation subunit is configured to install a first-type library, the pythonnet library and the virtual environment tool on the target terminal, the first-type library is configured to process data and network communication.

[0056] The environment construction subunit is configured to construct a running environment on the target terminal based on the first operating system based on the pythonnet library, the first-type library and the virtual environment tool on the target terminal.

[0057] The first running subunit is configured to receive a first calling instruction, run the first-type library according to the first calling instruction, and perform corresponding data processing and network communication in the virtual environment tool by the first-type library.

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

[0059] The running environment construction unit 21 comprises a second running subunit;

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

[0061] The environment construction subunit is configured to, in the running of the Linux system, construct a running environment based on a pythonnet library and a virtual environment tool, the pythonnet library is configured to load a target dynamic library under the Windows system, and the virtual environment tool is configured to provide a virtual environment for the running of the target dynamic library.

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

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

[0064] The exception repair unit is configured to, if there is a running exception in the virtual environment tool, perform exception capture and exception repair processing through a try-except block in the pythonnet library.

[0065] In an embodiment, the apparatus further comprises a calling type confirmation subunit;

[0066] The calling type confirmation subunit is configured to receive a dynamic library calling instruction, and confirm the type of the dynamic library currently called according to the dynamic library calling instruction.

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

[0068] In the running of the first operating system, a running 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 acquired, the running parameter corresponding to the target dynamic library is determined according to the use document, the library interface corresponding to the target dynamic library is called according to the running parameter in the virtual environment tool based on the pythonnet library, and the corresponding target dynamic library is run in the first operating system based on the library interface, so as to realize the function of the target dynamic library corresponding to the library interface. By using the above technical means, the library interface corresponding to the target dynamic library under the second operating system can be called in the virtual running environment constructed in the first operating system, so that the problem of low work efficiency caused by the conversion of system language in the process of cross-system calling of the dynamic library can be avoided. In the embodiment, the target dynamic library can be loaded into the virtual environment tool according to the specified loading path in the first operating system, and the library interface of the target dynamic library under the second operating system can be directly called in the virtual environment tool based on the running parameter, so that the corresponding target dynamic library can be run 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, the embodiment does not need to convert the system language, reduces the time of system language conversion, shortens the working time of the target dynamic library calling, and further improves the work efficiency of cross-system calling of the dynamic library.

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

[0070] The cross-system dynamic library calling device provided by the embodiment of the application can be used to execute the cross-system dynamic library calling method provided by the above embodiment, and has the corresponding functions and advantages. 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, the memory, the communication module, the input device, and the output device of the cross-system dynamic library calling device can be connected through a bus or other means.

[0071] The memory 32, as a computer readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules of the cross-system dynamic library calling method (for example, the running environment construction unit, the running parameter determination unit and the calling unit in the cross-system dynamic library calling apparatus) according to any embodiment of the present application. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs required by at least one function; the data storage area can store data created according to the use of the device, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device or other non-volatile solid-state storage device. In some examples, the memory can further include a memory remotely arranged with respect to the processor, which can be connected to the device through a network. Examples of the above 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 function applications and data processing of the device by running the software programs, instructions and modules stored in the memory, that is, implements the cross-system dynamic library calling method described above.

[0074] The input device 34 can 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 can include a display device such as a display screen.

[0075] The cross-system dynamic library calling apparatus provided above can be used to execute the cross-system dynamic library calling method provided by the above embodiments, and has corresponding functions and advantages.

[0076] The embodiment of the present application also provides a storage medium storing computer executable instructions, which, when executed by a computer processor, are used to execute a cross-system dynamic library calling method. The cross-system dynamic library calling method is used for a target terminal, the target terminal runs a first operating system, and a target dynamic library is a library in a second operating system, and the method comprises the following steps: constructing a running environment on the target terminal based on the first operating system 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 running of the target dynamic library; obtaining a usage document of the target dynamic library, and determining running parameters corresponding to the target dynamic library according to the usage document; in the virtual environment tool, the pythonnet library calls a corresponding library interface in the target dynamic library according to the running parameters, so as to realize a function corresponding to the library interface.

[0077] Storage medium – any type of memory device or storage device. The term “storage medium” is intended to include: mounting media, such as CD-ROM, floppy disk, or magnetic tape devices; 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 (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. Storage medium may also include other types of memory or combinations thereof. Furthermore, storage medium may reside in a first computer system in which the program is executed, or it may reside in a different second computer system 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” can include two or more storage media residing in different locations (e.g., in different computer systems connected via a network). Storage medium may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.

[0078] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the cross-system dynamic library calling method described above, but can also execute related operations in the cross-system dynamic library calling method provided in any embodiment of this 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 this 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 this application.

[0080] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application. The scope of this application is determined by the scope of the claims.

Claims

1. A cross-system dynamic library calling method, characterized in that, A target terminal, running a first operating system, a target dynamic library being a library in a second operating system, comprising: building a running environment on the target terminal based on the first operating system based on a pythonnet library and a virtual environment tool, the pythonnet library being used to load the target dynamic library under the second operating system, the virtual environment tool being used to provide a virtual environment for running of the target dynamic library; acquiring a usage document of the target dynamic library, and determining running parameters corresponding to the target dynamic library according to the usage document; in the virtual environment tool, the pythonnet library calling a corresponding library interface in the target dynamic library according to the running parameters, to realize a function corresponding to the library interface.

2. The method of claim 1, wherein, Before the pythonnet library calling the corresponding library interface in the target dynamic library according to the running parameters in the virtual environment tool, the method further comprises: in the virtual environment tool, acquiring a loading path of the target dynamic library pre-imported by the pythonnet library; loading the target dynamic library into the virtual environment tool according to the loading path by the pythonnet library.

3. The method of claim 1, wherein, The method of building the running environment on the target terminal based on the first operating system based on the pythonnet library and the virtual environment tool, comprising: installing a first type of library, the pythonnet library and the virtual environment tool in the target terminal, the first type of library being used to process data and network communication; building a running environment on the target terminal based on the first operating system based on the pythonnet library, the first type of library and the virtual environment tool; receiving a first calling instruction, and running the first type of library according to the first calling instruction, to perform corresponding data processing and network communication in the virtual environment tool by the first type of library.

4. The method of claim 1, wherein, The first operating system is a Linux system, and the second operating system is a Windows system; The method of building the running environment on the target terminal based on the first operating system based on the pythonnet library and the virtual environment tool, comprising: running the Linux system in the target terminal; building a running environment based on the pythonnet library and the virtual environment tool in the Linux system running, the pythonnet library being used to load the target dynamic library under the Windows system, and the virtual environment tool being used to provide a virtual environment for running of the target dynamic library.

5. The method of claim 2, wherein, The method of loading the target dynamic library into the virtual environment tool according to the loading path by the pythonnet library in the virtual environment tool, comprising: loading the target dynamic library into the virtual environment tool by a clr.AddReference function in the pythonnet library in the virtual environment tool.

6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: if there is a running exception in the virtual environment tool, performing exception capturing and exception repairing processing by a try-except block in the pythonnet library.

7. The method of claim 1, wherein, The method further includes: receiving a dynamic library calling instruction, and determining a type of a currently called dynamic library according to the dynamic library calling instruction; if the type is a dynamic library under a second operating system, obtaining a usage document of the target dynamic library.

8. A cross-system dynamic library calling device, characterized in that, A target terminal, running a first operating system, and a target dynamic library being a library in a second operating system, includes: a running environment construction unit, configured to construct a running environment on the target terminal based on the first operating system based on a pythonnet library and a virtual environment tool, the pythonnet library being used to load the target dynamic library under the second operating system, and the virtual environment tool being used to provide a virtual environment for running of the target dynamic library; a running parameter determination unit, configured to obtain a usage document of the target dynamic library, and determine a running parameter corresponding to the target dynamic library according to the usage document; a calling unit, configured to call, in the virtual environment tool, a library interface corresponding to the target dynamic library according to the running parameter by the pythonnet library, so as to implement a function corresponding to the library interface.

9. A cross-system dynamic library invocation device, comprising: include: a memory and one or more processors; the memory is configured 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 in any one of claims 1-7.

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

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