compile object files
gcc -c 1.c --> automatically generate 1.o file
link object files and generate binary file
gcc -o app 1.o 2.o main.o
build archives -- static library
ar cr libkido.a 1.o 2.o main.o
gcc -L . -lkido -o app
build shared library
gcc -c -fPIC 1.c --> automatically generate 1.o file
gcc -shared -fPIC -o libkido.so main.o 1.o 2.o
gcc -o app -L . -lkido -Wl,-rpath,./ <-- if rpath is not defined, LD_LIBRARY_PATH need to be defined in environment variable to have the binary locate library file
沒有留言:
張貼留言