<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>FYI, this is now fixed on current master via
<a class="moz-txt-link-freetext" href="https://github.com/pure-data/pure-data/commit/afb43ee827ee84ac79e1f03c56384d29e249f785">https://github.com/pure-data/pure-data/commit/afb43ee827ee84ac79e1f03c56384d29e249f785</a>.<br>
</p>
<p>Christof<br>
</p>
<div class="moz-cite-prefix">On 27.10.2020 16:49, Andi McClure
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAJDLOYK3EbWH=Ut_0bY0dauzy34_AX0=wvxg1bkkSh=Qao4uhw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">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.
<div><br>
</div>
<div>When it gets to the step of building libpd.so, it prints:</div>
<div>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>libpd/CMakeFiles/libpd.dir/pure-data/src/x_text.c.o:
In function `text_define_sort':</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>/path/to/repo/deps/libpd/pure-data/src/x_text.c:552:
undefined reference to `qsort_r'</span></p>
<div><br>
</div>
<div>I asked around about this, and was told a few things:</div>
<div>* Sometimes this kind of Android error magically goes
away if you fiddle with compileSdkVersion in gradle.</div>
<div>* There is a list in this git repo:</div>
<div> <a
href="https://android.googlesource.com/platform/bionic/+/master/libc/libc.map.txt"
moz-do-not-send="true">https://android.googlesource.com/platform/bionic/+/master/libc/libc.map.txt</a></div>
<div> 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.</div>
<div>* 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.</div>
<div><br>
</div>
<div>I found I was able to make it compile with the following
patch:</div>
<div><br>
</div>
<div>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><b>diff
--git a/src/x_text.c b/src/x_text.c</b></span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><b>index
44bf9521..18f3d9de 100644</b></span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><b>---
a/src/x_text.c</b></span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><b>+++
b/src/x_text.c</b></span></p>
<p class="gmail-p2"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(51,187,200)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures">@@
-474,9 +474,9 @@</span><span class="gmail-s2"
style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">
equal:</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>found in
msvcrt (which indeed it isn't in).<span
class="gmail-Apple-converted-space"> </span>Rather
than waste more time</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>on this,
just call qsort if we're Microsoft and single-instance.<span
class="gmail-Apple-converted-space"> </span>I hope
nobody</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>will try
to compile multi-instance Pd for 32-bit windows, but if
they</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>do, they
might run into my qsort_s problem again. */</span></p>
<p class="gmail-p3"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(195,55,32)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures">-#if
defined(_WIN32) && !defined(PDINSTANCE)</span></p>
<p class="gmail-p4"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,188,38)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures">+#if
(defined(_WIN32) || defined(__ANDROID__)) &&
!defined(PDINSTANCE)</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>#define
MICROSOFT_STUPID_SORT</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>static
void *stupid_zkeyinfo;</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>static int
stupid_sortcompare(const void *z1, const void *z2) {</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span
class="gmail-s1"
style="font-variant-ligatures:no-common-ligatures"><span
class="gmail-Apple-converted-space"> </span>return
(text_sortcompare(z1, z2, stupid_zkeyinfo)); }</span></p>
<p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br>
</p>
</div>
<div>So although I'm not exactly sure what x_text.c is doing
here, I am unblocked, I can proceed with my project as long
as I don't need multi-instance. But, I'd like to know, is
this a known problem? I find many references to people
building PureData on Android but no one seems to have hit
this issue. If there is a known working configuration for
PureData on Android, what git revision of PureData was it
building and what NDK compileSdkVersion? Alternately, is it
possible the problem is not with my configuration, but with
the libpd CMakeLists, and this problem would go away if I
added the right #define or -l link argument?</div>
<div><br>
</div>
<div>And if this is a new problem: Would a patch to address
this be welcome, and what approach would be preferred?
Should I just submit a patch triggering
MICROSOFT_STUPID_SORT when __ANDROID__ is present?</div>
<div><br>
</div>
<div>(I understand libpd is a different project from puredata
and apologize if this is the wrong place to ask given I'm
building libpd. However this seems (?) like a problem in
the pure-data part of the code.)</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Pd-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Pd-dev@lists.iem.at">Pd-dev@lists.iem.at</a>
<a class="moz-txt-link-freetext" href="https://lists.puredata.info/listinfo/pd-dev">https://lists.puredata.info/listinfo/pd-dev</a>
</pre>
</blockquote>
</body>
</html>