我有这样的目录结构
dir1
one.c
two.c
dir2
three_main.c
four.c
Run Code Online (Sandbox Code Playgroud)
我需要libdir1.so从所有c文件中创建一个共享库,并从所有c文件中dir1
创建一个可执行文件以及my_exedir2libdir1.so
我分两步创建.so和可执行文件。
.so step1: gcc -c -fPIC -g -O2 -pthread -o one.o one.c
gcc -c -fPIC -g -O2 -pthread -o two.o two.c
.so step2: gcc -shared -g -O2 -pthread -o libdir1.so one.o two.o
exe step1: gcc -c -fPIE -o three_main.o three_main.c
gcc -c -fPIE -o four.o four.c
exe step2: gcc -Wall -g -L -ldir1 -o my_exe three_main.o four.o
Run Code Online (Sandbox Code Playgroud)
现在我的问题是...... …