Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking failing for PCRE when using Android NDK stand-alone toolchain

People have been able to build PCRE (or a subset of) by copying the source files and creating appropriate Andriod.mk. I want to do similar, but using an Android stand-alone toolchain and just using their configure and make process. I have had success building other useful libraries using the same flow, but am running into an issue with PCRE. Specifically, late in the make flow I am getting this error:

undefined reference to__dso_handle' .libs/pcre_stringpiece.o

When doing this,

/bin/bash ./libtool --tag=CXX   --mode=link arm-linux-androideabi-g++  -O2 -version-info 0:0:0                             -o libpcrecpp.la -rpath /usr/local/lib pcrecpp.lo pcre_scanner.lo pcre_stringpiece.lo libpcre.la 
libtool: link: arm-linux-androideabi-g++  -fPIC -DPIC -shared -nostdlib   .libs/pcrecpp.o .libs/pcre_scanner.o .libs/pcre_stringpiece.o   -Wl,-rpath -Wl,/home/corbin/applications/pcre-8.21/.libs ./.libs/libpcre.so -L/home/corbin/my-android-toolchain-mod/bin/../lib/gcc/arm-linux-androideabi/4.7.0 -L/home/corbin/my-android-toolchain-mod/bin/../lib/gcc -L/home/corbin/my-android-toolchain-mod/bin/../lib/gcc/arm-linux-androideabi/4.7.0/../../../../arm-linux-androideabi/lib -L/home/corbin/my-android-toolchain-mod/bin/../sysroot/usr/lib -lstdc++ -lm -lc -ldl -lgcc   -O2   -Wl,-soname -Wl,libpcrecpp.so.0 -o .libs/libpcrecpp.so.0.0.0
.libs/pcrecpp.o: In function `_GLOBAL__sub_I_pcrecpp.cc':
pcrecpp.cc:(.text.startup+0x94): undefined reference to `__dso_handle'
.libs/pcre_stringpiece.o: In function `_GLOBAL__sub_I_pcre_stringpiece.cc':
pcre_stringpiece.cc:(.text.startup+0x40): undefined reference to `__dso_handle'
collect2: error: ld returned 1 exit status
make[1]: *** [libpcrecpp.la] Error 1
make[1]: Leaving directory `/home/corbin/applications/pcre-8.21'

Any thoughts on what the problem is and what the solution is? I read various things about similar problems, but they were mostly unhelpful or it wasn't clear if they related to the same problem.

Update 1: I have found that this problem does not occur when I use the default stand-alone toolchain. It only happens when I use a modified one as described here: http://specificimpulses.blogspot.com/2011/10/android-fortran-step-by-step-part-2.html I need to use that one for building other libraries which include fortran (and have successfully done so) and want to use the same toolchain for all builds. So, do I need to rebuild the toolchain with some different options?

like image 825
corbin Avatar asked Nov 14 '22 11:11

corbin


1 Answers

Looks like -fno-use-cxa-atexit is an acceptable workaround.

like image 142
corbin Avatar answered Nov 16 '22 02:11

corbin