Link shared library with C ++ shared libraries
I have successfully created a shared library, libA.so .
All classes inside, have namspace common :: A
ldd libA.so
linux-vdso.so.1 => (0x00007fffd632d000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f6497d19000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6497b03000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6497743000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6497447000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6498243000)
Then I need to create another library B that uses A. So I link it (-lA and -L <path_to_A>) and also compile with _I /. All classes inside, have namspace common :: B
Compile and build libB.so , but:
1) Elipse puts a red X in the code where I call A methods:
Multiple markers at this line
- Symbol '<A_method>' could not be resolved
- Function '<A_method>' could not be resolved
2) Library A seems to be unrelated to B:
ldd libB.so
linux-vdso.so.1 => (0x00007fffbcbfe000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f695ca59000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f695c842000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f695c483000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f695bf7e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f695d1d9000)
I don't understand why I have no reference to A:
libA.so => .....
Any ideas?
Update
This is the makefile (autogenerated by eclipse):
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/network/mqtt/subdir.mk
-include src/data/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: libB.so
# Tool invocations
libB.so: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
g++ -L/path_where_is_A_so/ -shared -o "libB.so" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(LIBRARIES)$(CC_DEPS)$(C++_DEPS)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) libB.so
-@echo ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
+3
source to share