gcc compile dynamic library

1. Compilation instructions

gcc  -shared -fPCI -o libmyhello.so hello.c  

2. Link compilation instructions

gcc main.c -I/usr/local/include -L/*/ -lmyhello 

-I (i uppercase) followed by the connector file directory

-L followed by dynamic library directory

3. Set environment variables

Reference https://mp.csdn.net/editor/html/114375663

4. Call

./a.out

5. Analyze the instruction ldd

ldd+object file, can analyze the link situation of the object file library

Such as ldd a.out

 

Guess you like

Origin blog.csdn.net/qq_37061368/article/details/114376220