1
나는 두 개의 기존 C++ 라이브러리, library1
및 library2
에 연결해야하는 myCode
을 쓰고있는 다중 스레드 C++ 패키지 용 Makefile을 가지고 있습니다. myCode
은 현재 ~ 7 *.cpp
개의 파일과 헤더 파일로 구성되어 있습니다.공유 객체/공유 라이브러리가 올바르게 컴파일되었는지 어떻게 테스트합니까?
LIBRARY1_DIR := ./library1/
LIBRARY2_DIR := ./library2/
ABS_LIBRARY1_DIR := $(realpath $(LIBRARY1_DIR))
ABS_LIBRARY2_DIR := $(realpath $(LIBRARY2_DIR))
CXX := g++
CXXFLAGS := -Wno-deprecated -Wall -O3 -fexceptions -g -Wl,-rpath,$(ABS_LIBRARY1_DIR)/lib/
INCLUDES := -I$(ABS_LIBRARY1_DIR)/include/ -I$(ABS_LIBRARY2_DIR)/ -L$(ABS_LIBRARY1_DIR)/lib/ -L$(ABS_LIBRARY2_DIR)/
all: library1 library2 myCode
.PHONY : myCode
myCode: file1.cpp file2.cpp file3.hh file3.cpp file4.hh file4.cpp file5.cpp file5.hh file6.hh file6.hh file7.cpp file7.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) file1.cpp file2.cpp -o myCode.so $(ABS_LIBRARY2_DIR)/importfile1.a -lz -ldl -llibrary1 -lpthread -fPIC -shared
.PHONY : library1
library1:
mkdir $(ABS_LIBRARY1_DIR)/build; cd $(ABS_LIBRARY1_DIR)/build; cmake ..; make; cd ../
.PHONY : library2
library2:
cd $(ABS_LIBRARY2_DIR); ./configure; make; cd ../
#.PHONY : clean
clean:
rm myCode.so; rm -rf $(ABS_LIBRARY1_DIR)/build; rm -rf $(ABS_LIBRARY1_DIR)/include; rm -rf $(ABS_LIBRARY1_DIR)/lib; rm -rf $(ABS_LIBRARY1_DIR)/bin; cd $(ABS_LIBRARY2_DIR); make clean;
질문 : 어떻게 공유 라이브러리가 제대로 작성되었는지 테스트합니까
의 I는 플래그 -fPIC
및 -shared
을 포함 시켰함으로써 출력 공유 라이브러리 myCode.so
에 의미 다음? 이 방법을 사용할 수있는 방법이 있습니까?