linux下编译 静态库、动态库,动态库依赖静态库
xx.o : xx.h xx.cpp gcc -g -Wall -fPIC -std=c++11 -lstdc++ -o xx.o -c xx.cpp -I ./ libxx.a : xx.o ar -crv libxx.a xx.o libTest.so : loadClass.cpp loadClass.h gcc -g -Wall -shared -fPIC -std=c++11 -lstdc++ -o libTest.so loadClass.cpp -I ./ libshared.so: shared.cpp shared.h gcc -g -Wall -shared -fPIC -std=c++11 -lstdc++ -o libshared.so shared.cpp -I ./ libxxCheck.so : xxCheck.cpp xxCheckClass.cpp libxx.a gcc -g -Wall -fPIC -shared -std=c++11 -lstdc++ -o libxxCheck.so xxCheck.cpp xxCheckClass.cpp -I ./ -L. -Xlinker --start-group -lLogic -Xlinker --end-group #-Xlinker --start-group -lLogic -Xlinker --end-group描述依赖的静态库 Main: main.cpp libTest.so libxxCheck.so gcc -g -Wall -std=c++11 -lstdc++ -o Main main.cpp -I ./ -L ./ -lshared -Wl,-rpath=. -ldl -rdynamic -lTest -lLogicCheck All: xx.o libxx.a libTest.so libshared.so libxxCheck.so Main clean: rm -rf xx.o libxx.a libTest.so libshared.so Main libxxCheck.so
#if (defined _WIN32 || defined _WIN64 || defined WIN32 || defined WIN64)
-Wl,-rpath=./ -Wl,-rpath-link=