Ticket #3 (closed defect: fixed)
Link error when using user defined .so libraries in command line
| Reported by: | dmc | Owned by: | dmc |
|---|---|---|---|
| Priority: | major | Milestone: | r3-crystax-3 |
| Component: | ndk | Version: | r3-crystax-2 |
| Severity: | Keywords: | ||
| Cc: | Blocked By: | ||
| Blocking: |
Description
Using of user defined .so libraries in command line can cause linker errors when these libraries use C++ features defined in libstdc++/libsupc++. Errors like 'std::vector<....> is not defined'.
Change History
Note: See
TracTickets for help on using
tickets.
This is because libstdc++/libsupc++ are before user defined .so libraries in command line. Looking in build/toolchains/arm-eabi-X.X.X/setup.mk, there is following procedure:
define cmd-build-shared-library $(TARGET_CC) \ -nostdlib -Wl,-soname,$(notdir $@) \ -Wl,-shared,-Bsymbolic \ $(PRIVATE_OBJECTS) \ -Wl,--whole-archive \ $(PRIVATE_WHOLE_STATIC_LIBRARIES) \ -Wl,--no-whole-archive \ $(PRIVATE_STATIC_LIBRARIES) \ $(TARGET_CXXLIBS) \ $(TARGET_LIBGCC) \ $(PRIVATE_SHARED_LIBRARIES) \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_LDLIBS) \ -o $@ endefActual fix is adding TARGET_CXXLIBS and TARGET_LIBGCC to command line twice - one time before PRIVATE_XXX and second - after. This approach will not add any unneeded symbols to the final binary (so application will stay binary compatible with thus built with Google NDK) but will effectively add all required stuff from libstdc++/libsupc++.