0
私の1つのプロジェクトの共有(動的)ライブラリ.soまたは.dylibを別のプロジェクトにリンクする際に問題があります。Makefileリンク共有(ダイナミック)ライブラリ
私は、このようなMakefileを使用しています:
#libraries
#custom
COMPARERS_STATIC_LIB_PATH=../comparers/output/debug/lib/libcomparers.a
COMPARERS_LIB_DIR=../comparers/output/debug/lib/
$(SHARED_LIBRARY): assertion.o
$(CC) $(CFLAGS) -L$(COMPARERS_LIB_DIR) -shared -o $(OUTPUTS_LIB_DIR)/$(SHARED_LIBRARY) $(OUTPUTS_DIR)/assertion.o -lcomparers
$(DYNAMIC_LIBRARY): assertion.o
$(CC) $(CFLAGS) -L$(COMPARERS_LIB_DIR) -dynamiclib -o $(OUTPUTS_LIB_DIR)/$(DYNAMIC_LIBRARY) $(OUTPUTS_DIR)/assertion.o -lcomparers
ディレクトリとライブラリは、以下の絵のような場所です。
正しく静的ライブラリのコンパイルとリンクとのリンク:
$(TARGET): $(LIBRARY)
$(CC) $(CFLAGS) -o $(OUTPUTS_BIN_DIR)/$(TARGET) src/main.c $(OUTPUTS_LIB_DIR)/$(LIBRARY) $(COMPARERS_STATIC_LIB_PATH)
エラーを私が手:
gcc -g -Wall -D__USE_FIXED_PROTOTYPES__ -std=c99 -I./include -I../comparers/include -L../comparers/output/debug/lib/ -shared -o outputs/debug/lib/libunit_tests.so outputs/debug/assertion.o -lcomparers
ld: warning: directory not found for option '-L../comparers/output/debug/lib/'
ld: library not found for -lcomparers
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libunit_tests.so] Error 1
ええ、ばかげたエラーです。どうも。 –