Patent ID: 7890944

Claim:
A method for sharing static link codes by software components in a dynamic link library (DLL) and a main program, which is implemented in a memory and applicable to an embedded system with the memory, the main program linking to at least one static link library and a program code, the method comprising the steps of: (A) creating, in the main program, a function pointer structure for corresponding to the at least one static link library and a link between the function pointer structure and corresponding functions of the at least one static link library; (B) creating, in the main program, a variable pointer for corresponding to the at least one static link library and a link between the variable pointer and corresponding variables of the at least one static link library; (C) changing function calls in a program code of the dynamic link library that call the at least one static link library into corresponding function pointer variables of the function pointer structure; (D) changing variables of the program code of the dynamic link library that pass through the at least one static link library into corresponding variable pointers; (E) compiling the program code of the dynamic link library into the dynamic link library, loading the dynamic link library in the main program, and passing memory addresses of the functions and variables from the main program to the dynamic link library; and (F) changing corresponding functions and variables, which call the at least one static link library, of the dynamic link library based on the memory addresses of the functions and variables passed on by the main program when the dynamic link library corresponding to the program code is loaded into the main program.