Qusay static to a dynamic library

Objective: libimp.a libalog.a with source code and business packed into libaudioplug.so go inside.

Summary: libimp.a libalog.a file in order to be packaged into ibaudioplug.so go inside, you must compile the source code and compile business libimp.a libalog.a time when all

Use -fPIC, to the three combined.

    To achieve on the use of dynamic libraries libimp.so libalog.so, will be able to connect to get away, run-time, you need to libaudioplug.so libimp.so libalog.so three libraries.

-------------------------------------------------- behind the experiment is ------------------------------ ---------------- -------------------------------------------
    1)
    JZ_STATIC_LIBS: = $ ( JZ_SDK_PATH) /lib/uclibc/libimp.a $ (JZ_SDK_PATH) /lib/uclibc/libalog.a
    lib: $ (PLUG_SRC)
        mips-the GNU-Linux-uclibc-G ++ -fPIC -shared $ ^ $ (JZ_STATIC_LIBS) $ (INC_PATH ) -o libaudioplug.so
    
    error:

    /home/yp/toolchains/T20_toolchain/mips-gcc472-glibc216-32bit/bin/../lib/gcc/mips-linux-gnu/4.7.2/../../../../mips-linux-gnu/bin/ld: ./jz_lib/MergeBaseMove.c.o:
    relocation R_MIPS_HI16 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
    ./jz_lib/MergeBaseMove.c.o: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    Makefile:32: recipe for target 'lib' failed
    make: *** [lib] Error 1


    2)
    then I will use ar connected into a static library .o files, try again
    
    JZ_LIB_OBJ: = ./jz_lib/*.o    
    
    JZ_STATIC_LIBS: = $ (JZ_SDK_PATH) /lib/uclibc/libimp.a $ (JZ_SDK_PATH) / lib / uclibc / libalog.a
    lib: $ (PLUG_SRC)
        mips-the GNU-Linux-uclibc-G ++ -fPIC -shared $ ^ $ (JZ_LIB_OBJ) $ (INC_PATH) -o libaudioplug.so
        
    reported the same mistake.
    
    3)
    I tried it
    lib: $ (PLUG_SRC)
        mips-the GNU-Linux-uclibc-G ++ -fPIC -shared $ (JZ_LIB_OBJ) $ ^ $ (INC_PATH) -o libaudioplug.so
        
    same misstatements.    

    
    4)
    I also tried it
    lib: $ (PLUG_SRC)
        mips-the GNU-Linux-uclibc-G ++ -fPIC -shared $ (JZ_STATIC_LIBS) $ ^ $ (INC_PATH) -o libaudioplug.so
        
    compiled, and then I got start using this DLL, the results just call this function on JZ_STATIC_LIBS mistakes.
    
    5)
    I went and tried it, I do not add this static library, also compiled before. Run a program or segment error
    lib: $ (PLUG_SRC)
        mips-the GNU-Linux-uclibc-G ++ -fPIC -shared $ ^ $ (INC_PATH) -o libaudioplug.so
        
    6)
    I and they tried it, I do not add this static library, when in use, will add static library, compiled and took another. Run a program or another and mistakes.
    lib: $ (PLUG_SRC)
        mips-the GNU-Linux-uclibc-G ++ -fPIC -shared $ ^ $ (INC_PATH) -o libaudioplug.so
        
        
    7) and I tried it and they will be replaced with the original static library use DLL compiled a test program had experienced. Consummation.
        
        
    lib: $ (PLUG_SRC)
        mips-linux-uclibc-gnu- g ++ -fPIC -shared $ ^ -limp -lalog $ (LIB_PATH) $ (INC_PATH) -o libaudioplug.so
        
    
        
        
    seems his mother to get dynamic library static library, it is difficult ah.    
    
    
Summary: This is a compilation sequence there are problems, there is a compiler option issue.
    The order of compilation problem then, I do not want to explore, in fact, calls between static library is a sequential problem.
    Compiler option problem is -fPIC, this option is to be generated when all the .o should be added, so you can put a static to a dynamic library Qusay.
    Because the king is not using the library -fPIC so fail to realize static to dynamic library inside Qusay
 

Guess you like

Origin blog.csdn.net/qq_16810885/article/details/94036214