====== C++ compile link ====== ===== ENV Variables ===== This is output from ./configure --help CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path The resulting compile command will be: $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5 /home/td/src/dtn/android-toolchain-p8/bin/arm-linux-androideabi-g++ \ -g --sysroot=/home/td/src/dtn/android-toolchain-p8/sysroot \ -I/home/td/src/dtn/ibrdtn_ndk/target/include -I/home/td/src/dtn/ibrdtn_ndk/target/include/netlink -I/home/td/src/dtn/ibrdtn_ndk/target/include -I/home/td/src/dtn/ibrdtn_ndk/target/include/libnl3 -I/home/td/devfs/opt/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include -DANDROID \ -Wl,-rpath-link=/home/td/src/dtn/android-toolchain-p8/lib/gcc/arm-linux-androideabi/4.4.3 -nostdlib -o dtnd Main.o \ -L/home/td/src/dtn/ibrdtn_ndk/ibrcommon-0.6.5/ibrcommon/.libs -L/home/td/src/dtn/ibrdtn_ndk/ibrdtn-0.6.5/ibrdtn/.libs -L/home/td/devfs/opt/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/libs/armeabi -L/home/td/src/dtn/ibrdtn_ndk/target/lib \ ./.libs/libdtnd.a -lnl /home/td/src/dtn/ibrdtn_ndk/ibrdtn-0.6.5/ibrdtn/.libs/libibrdtn.a /home/td/src/dtn/ibrdtn_ndk/ibrcommon-0.6.5/ibrcommon/.libs/libibrcommon.a -lgnustl_shared -lsupc++ -lstdc++ /home/td/src/dtn/android-toolchain-p8/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a -lc -lm ===== Compile ===== ===== Linking ===== ==== Archive ==== --whole-archive --no-whole-archive Like in dynamic linking (?) symbols in an archive are only linked when they are needed. So it's important to use the correct order libb, liba (where libb uses symboles in liba). To tell ld to link the whole archive one can use the --whole-archive libx liby --no-whole-archive ( or -Wl,-whole-archive and -Wl,-no-whole-archive when input to g++). When passed to LDFLAGS this order is brocken --> TODO find solution. When compiled, archive is treated as collection of objects so just put it behind -I... in gcc command. If the result is an archive, itt will be nested in the resulting archive.