Ticket #3 (closed defect: fixed)

Opened 22 months ago

Last modified 21 months ago

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

comment:1 Changed 22 months ago by dmc

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 $@
endef

Actual 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++.

comment:2 Changed 22 months ago by dmc

  • Status changed from new to closed
  • Resolution set to fixed

Fixed. Will be included to r3-crystax-3.

comment:3 Changed 21 months ago by dmc

  • Milestone set to r3-crystax-3
Note: See TracTickets for help on using tickets.