[PD-dev] qsort_r failure building puredata on Android?

Christof Ressi info at christofressi.com
Tue Oct 27 18:35:34 CET 2020

Hey, I've just updated the PR to also use "STUPID_SORT" on Android.


On 27.10.2020 18:17, Claude Heiland-Allen wrote:
> Hi Andi,
> On 27/10/2020 15:49, Andi McClure wrote:
>> I am building puredata via libpd on Android (a fork off 
>> 0.51/d5766fd0). I am doing this by loading the libpd CMakeLists.txt 
>> from my own CMakeLists invoked from gradle and then linking libpd in 
>> my Android app.
>> When it gets to the step of building libpd.so, it prints:
>> libpd/CMakeFiles/libpd.dir/pure-data/src/x_text.c.o: In function 
>> `text_define_sort':
>> /path/to/repo/deps/libpd/pure-data/src/x_text.c:552: undefined 
>> reference to `qsort_r'
> I ran into this compiling libpd to run in the browser with Emscripten, 
> ended up writing my own qsort_r that wraps qsort. I haven't tested it 
> much though.  There are a couple of follow-up commits so this diff 
> isn't quite the whole story:
> https://github.com/claudeha/pure-data/commit/e8023866ef8be3475cc101cfb1656f5249030875#diff-e11aa02617b1aa9f0aa34c6e0b8c21b98b1fcee3324d88e839579e6f66923ef3 
> https://github.com/pure-data/pure-data/issues/675 is an issue with a 
> pull request, that's probably a bit nicer than my patched branch that 
> is way behind upstream...
> Maybe other systems than Emscripten and Android are broken, anyone 
> using a BSD or Linux which doesn't use glibc for example?
>> I asked around about this, and was told a few things:
>> * Sometimes this kind of Android error magically goes away if you 
>> fiddle with compileSdkVersion in gradle.
>> * There is a list in this git repo:
>> https://android.googlesource.com/platform/bionic/+/master/libc/libc.map.txt 
>>    Of which libc symbols wind up in which binary in Android. However, 
>> in current Android master, qsort_r is not in this list at all. Only 
>> qsort.
>> * qsort_r is not a standard C function, it is a GNU thing, so it's 
>> possible Android really just doesn't have it. If Android really 
>> doesn't provide quicksort, it *might* be possible to fake qsort_r by 
>> adding a single C++ file which wraps std::sort (this was added in 
>> C++03 so Android *probably* has it), which doesn't have standard C 
>> qsort's reentrancy problem.
> Claude

More information about the Pd-dev mailing list