2017-08-11 2 views
0

J'ai un problème avec les bibliothèques partagées (dynamiques) .so ou .dylib de mon projet avec un autre projet.Bibliothèques partagées (dynamiques) du lien Makefile

J'utilise comme 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 

Les répertoires et les bibliothèques sont en place sur l'image ci-dessous.

enter image description here

Liaison avec compiles de bibliothèque statique et des liens correctement:

$(TARGET): $(LIBRARY) 
    $(CC) $(CFLAGS) -o $(OUTPUTS_BIN_DIR)/$(TARGET) src/main.c $(OUTPUTS_LIB_DIR)/$(LIBRARY) $(COMPARERS_STATIC_LIB_PATH) 

L'erreur que je reçois:

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 

Répondre

1

Vous avez une faute de frappe, votre $(COMPARERS_LIB_DIR) contient:

../comparers/output/debug/lib/ 

mais doit être:

../comparers/outputs/debug/lib/ 
       ^

concernant votre figure.

+0

Oui, erreur stupide. THX. –