CDP8 icon indicating copy to clipboard operation
CDP8 copied to clipboard

Building CDP8 on Termux gives errors about POS64

Open visagemsc opened this issue 4 months ago • 6 comments

As the title says, I can't build CDP8 without errors about POS64 (member reference base type 'fpos_t' (aka 'long') is not a structure or union).

Compiler:

clang version 20.1.8
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
Found candidate GCC installation: /data/data/com.termux/files/usr/bin/../../usr/lib/gcc/aarch64-linux-android/8.3.0
Found candidate GCC installation: /data/data/com.termux/files/usr/bin/../lib/gcc/aarch64-linux-android/8.3.0

visagemsc avatar Aug 25 '25 12:08 visagemsc

Thanks for the bug report. As you will have seen, ”POS64” is intended to cover multiple platforms and architectures, not least WIN32 systems where a “long” is only 32bits. This has clearly slipped through the net, so to speak. I will look into it and make whatever changes are needed. It would be helpful to confirm this is in “sfsysnew” code, somewhere. RD.

On 25 Aug 2025, at 13:53, VISΛGE @.***> wrote:

visagemsc created an issue (ComposersDesktop/CDP8#17) As the title says, I can't build CDP8 without errors about POS64 (member reference base type 'fpos_t' (aka 'long') is not a structure or union). Compiler: clang version 20.1.8 Target: aarch64-unknown-linux-android24 Thread model: posix InstalledDir: /data/data/com.termux/files/usr/bin Found candidate GCC installation: /data/data/com.termux/files/usr/bin/../../usr/lib/gcc/aarch64-linux-android/8.3.0 Found candidate GCC installation: /data/data/com.termux/files/usr/bin/../lib/gcc/aarch64-linux-android/8.3.0

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

richarddobson avatar Aug 25 '25 13:08 richarddobson

Yeah they definitely do come from "dev/newsfsys/sfsys.c". Here's a straight copypaste from Termux, sorry if it's a bit janky.

[  2%] Building C object dev/newsfsys/CMakeFiles/sfsys.dir/sfsys.c.o
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1074:26: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1074 |     if(fseeko(f->fileno, POS64(f->propoffset), SEEK_SET)
      |                          ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1103:29: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1103 |                     ||(int)(POS64(f->propoffset)) >= 0
      |                             ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1188:5: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1188 |     POS64(f->propoffset) = (unsigned) -1;
      |     ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1189:5: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1189 |     POS64(f->factchunkoffset) = (unsigned) -1;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1349:29: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1349 |                             POS64(bytepos) = size-sizeof(DWORD);
      |                             ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1350:72: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1350 |                             if(fseeko(f->fileno, /*size-sizeof(DWORD)*/POS64(bytepos), SEEK_CUR) < 0)
      |                                                                        ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1462:21: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1462 |                     POS64(bytepos) = POS64(f->datachunkoffset) + size;
      |                     ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1462:38: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1462 |                     POS64(bytepos) = POS64(f->datachunkoffset) + size;
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1703:5: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1703 |     POS64(bytepos) = 0;
      |     ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:1707:5: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 1707 |     POS64(f->propoffset) = 0;
      |     ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2040:9: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2040 |         POS64(bytepos) = 0;
      |         ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2064:9: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2064 |         POS64(f->propoffset) = -1;
      |         ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2192:13: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2192 |             POS64(bytepos) += ((size+1)&~1) - 2 *sizeof(DWORD);
      |             ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2205:25: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2205 |                         POS64(f->datachunkoffset) += ssnd_offset;
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2220:36: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2220 |                                 if(POS64(f->propoffset) >= 0
      |                                    ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2230:17: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2230 |                 POS64(f->propoffset) = POS64(bytepos);
      |                 ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2230:40: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2230 |                 POS64(f->propoffset) = POS64(bytepos);
      |                                        ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2381:9: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2381 |         POS64(f->propoffset) = -1;
      |         ^~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:2583:13: error: member reference base type 'fpos_t' (aka 'long') is not a structure or union
 2583 |             POS64(bytepos) = ((size+1)&~1) - 2 *sizeof(DWORD);
      |             ^~~~~~~~~~~~~~
/data/data/com.termux/files/home/CDP8/dev/newsfsys/sfsys.c:284:20: note: expanded from macro 'POS64'
  284 | #define POS64(x) (x.__pos)
      |                   ~^~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

visagemsc avatar Aug 27 '25 01:08 visagemsc

Found the issue thanks to one clever person. (x.__pos) was strictly a GLIBC thing and doesn't occur in other libraries, including bionic, Android's own C library. Already made a pull request regarding this.

visagemsc avatar Aug 29 '25 21:08 visagemsc

@visagemsc does your pull request 100% compile successfully and work on Android yet, or do you still need some more help to progress further?

I have made a Soft Fork of CDP8 for Android (Termux)

(a script that heavily patches the code of CDP8 to build inside Termux which, unlike a hard fork that would be committed to a repository and would require more manual maintenance to bump, can be deleted and re-run anytime to fetch a new upstream commit and re-patch and re-compile it to build for Android in Termux)

here is my script and I hope that if you still need help, this helps you,

but if you already have it completely figured out then you might not need this anymore.

Image
pkg upgrade
pkg install git build-essential cmake dos2unix libandroid-glob portaudio-static
git clone https://github.com/ComposersDesktop/CDP8.git
# the software is written by a developer of Windows software,
# so unfortunately they commit CRLF line endings to
# some files and, experienced users of UNIX-like
# operating systems know that unfortunately,
# it's necessary to preemptively use this command
# on any local clones of CRLF repos that will be
# edited in any way on the UNIX-like operating system
# in order to avoid a lot
# of annoying problems that can happen from
# attempting to use CRLF-ended text files on
# UNIX-like operating systems.
find CDP8 -type f -print0 | xargs -0 dos2unix
tar xvf CDP8/libaaio/libaaio-0.3.1.tar.bz2 --strip-components=1 -C CDP8/libaaio/
rm CDP8/libaaio/libaaio-0.3.1.tar.bz2
cd CDP8
# make a local fork in which all code is tracked in
# a style that is friendly to development on UNIX-like operating systems
# the purpose of this is to make development for
# a fork of this software for Android or other UNIX-like
# operating systems more convenient.
# the downside is that any changes made will not be
# easily upstreamable to the repository where the
# developer of the Windows version is storing their code,
# but the advantage is that it avoids inconvenient
# barriers to writing and applying patches to the code
# through the command line of a UNIX-like operating system.
git add .
git commit -m "tmp"
# these are the patches which can fix your actual errors.
# the changes involve workarounds for several GNU-isms and
# Windows-isms written by the upstream developer, who is
# understandably likely focused on Windows and might not have
# the resources to maintain support for alternative UNIX-like operating systems.
git apply -v << 'EOF'
--- a/dev/externals/mctools/chxformat.c
+++ b/dev/externals/mctools/chxformat.c
@@ -41,7 +41,7 @@ char* guidnames[] = {"PCM","PCM FLOAT","AMB PCM","AMB FLOAT"};
 #define REVWBYTES(t)    ( (((t)&0xff) << 8) | (((t)>>8) &0xff) )
 #define TAG(a,b,c,d)    ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
 
-#ifdef linux
+#if defined(linux) && !defined(__ANDROID__)
 #define POS64(x) (x.__pos)
 #else
 #define POS64(x) (x)
--- a/dev/externals/portsf/portsf.c
+++ b/dev/externals/portsf/portsf.c
@@ -90,7 +90,7 @@ int stricmp(const char *a, const char *b);
 int strnicmp(const char *a, const char *b, const int length);
 #endif
 
-#ifdef linux
+#if defined(linux) && !defined(__ANDROID__)
 #define POS64(x) (x.__pos)
 #else
 #define POS64(x) (x)
--- a/dev/newsfsys/sfsys.c
+++ b/dev/newsfsys/sfsys.c
@@ -280,7 +280,7 @@ extern int sampsize[];
 #define sizeof_WFMTEX (40)
 
 
-#ifdef linux
+#if defined(linux) && !defined(__ANDROID__)
 #define POS64(x) (x.__pos)
 #else
 #define POS64(x) (x)
--- a/dev/sfsys/sfsys.c
+++ b/dev/sfsys/sfsys.c
@@ -274,7 +274,7 @@ extern int sampsize[];
 #define sizeof_WFMTEX (40)
 
 
-#ifdef linux
+#if defined(linux) && !defined(__ANDROID__)
 #define POS64(x) (x.__pos)
 #else
 #define POS64(x) (x)
--- a/dev/externals/paprogs/pvplay/CMakeLists.txt
+++ b/dev/externals/paprogs/pvplay/CMakeLists.txt
@@ -32,7 +32,7 @@ link_directories( ../../lib  ../../../newsfsys ../../../pvxio2)
 # need /usr/local/include here?
 include_directories(/usr/local/include ../../../newinclude ../include ../portaudio/include ../portaudio/src/common)
 #../portaudio/src/common/pa_ringbuffer.c
-add_executable(pvplay pvplay.cpp pvoc2.cpp fmhfuncs.c pvthreads.cpp mxfft.c)
+add_executable(pvplay pvplay.cpp pvoc2.cpp fmhfuncs.c pvthreads.cpp mxfft.c ../pa_ringbuffer.c)
 target_link_libraries(pvplay sfsys pvxio2 ${EXTRA_LIBRARIES1})
 
 my_install(pvplay)
--- a/dev/externals/paprogs/paplay/CMakeLists.txt
+++ b/dev/externals/paprogs/paplay/CMakeLists.txt
@@ -35,7 +35,7 @@ include_directories(../../include ../include ../portaudio/include ../portaudio/s
 if(MINGW)
 add_executable(paplay paplay.c fmhfuncs.c cmakedummy.cpp)
 else()
-add_executable(paplay paplay.c fmhfuncs.c )
+add_executable(paplay paplay.c fmhfuncs.c ../pa_ringbuffer.c)
 endif()
 target_link_libraries(paplay ${EXTRA_LIBRARIES1})
 
--- a/dev/externals/paprogs/recsf/CMakeLists.txt
+++ b/dev/externals/paprogs/recsf/CMakeLists.txt
@@ -33,7 +33,7 @@ include_directories(../../include ../portaudio/include ../portaudio/src/common /
 if(MINGW)
     add_executable(recsf recsf.c cmakedummy.cpp)
 else()
-    add_executable(recsf recsf.c)
+    add_executable(recsf recsf.c ../pa_ringbuffer.c)
 endif()
 target_link_libraries(recsf portsf ${EXTRA_LIBRARIES1})
 
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,7 +119,7 @@ if(WIN32)
         oleaut32
         uuid)
     else()
-      set(EXTRA_LIBRARIES "m")
+      set(EXTRA_LIBRARIES "m" "OpenSLES")
 endif(WIN32)
 
 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
EOF
# the build system of the software is unfortunately written in an inconvenient way
# that doesn't allow easily adding additional compiler arguments, so just stuff
# all the needed arguments into places where they work.
find . -type f | xargs -n 1 sed -i \
    -e "s|-Dunix|$(pkg-config --libs portaudiocpp) -landroid-glob -D__USE_BSD -Dunix|g" \
    -e "s|PaUtil_AllocateMemory|PaUtil_AllocateZeroInitializedMemory|g"
# this software uses internal portaudio code that is not intended for public use by upstream portaudio.
curl https://raw.githubusercontent.com/PortAudio/portaudio/57aa393109ec996799d3a5846c9ecb0a65b64644/src/common/pa_ringbuffer.h > dev/include/pa_ringbuffer.h
curl https://raw.githubusercontent.com/PortAudio/portaudio/57aa393109ec996799d3a5846c9ecb0a65b64644/src/common/pa_memorybarrier.h > dev/include/pa_memorybarrier.h
curl https://raw.githubusercontent.com/PortAudio/portaudio/57aa393109ec996799d3a5846c9ecb0a65b64644/src/common/pa_util.h > dev/include/pa_util.h
curl https://raw.githubusercontent.com/PortAudio/portaudio/57aa393109ec996799d3a5846c9ecb0a65b64644/src/common/pa_ringbuffer.c > dev/externals/paprogs/pa_ringbuffer.c
# install a timeb polyfill for Android
# that I copied and pasted from the 8086tiny package
mkdir dev/include/sys
cat << 'EOF' > dev/include/sys/timeb.h
#ifndef _TIMEB_H
#define _TIMEB_H

#include <time.h>

struct timeb {
	time_t time;        /* Seconds since epoch, as from `time'.  */
	unsigned short int millitm; /* Additional milliseconds.  */
	short int timezone;     /* Minutes west of GMT.  */
	short int dstflag;      /* Nonzero if Daylight Savings Time used.  */
};

static int ftime(struct timeb *tb)
{
	struct timeval  tv;
	struct timezone tz;

	if (gettimeofday (&tv, &tz) < 0)
		return -1;

	tb->time    = tv.tv_sec;
	tb->millitm = (tv.tv_usec + 500) / 1000;

	if (tb->millitm == 1000) {
		++tb->time;
		tb->millitm = 0;
	}
	tb->timezone = tz.tz_minuteswest;
	tb->dstflag  = tz.tz_dsttime;

	return 0;
}

#endif
EOF
cd libaaio/
autoreconf -fi
# warning this will install libaaio manually into your Termux $PREFIX
# without package management, but the software libaaio is
# not widely used and is unlikely to conflict with anything else
./configure --prefix=$PREFIX
make
make install
cd ..
mkdir build
cd build
cmake ..
make

robertkirkman avatar Sep 01 '25 04:09 robertkirkman

And I almost forgot to document that this soft fork is forked from commit 7bc86cea179d51bc84b97620f5747b597923c71f, so if its patches fail to apply in the future, future readers just need to use this command after cloning the repository and changing directory to it:

git checkout 7bc86cea179d51bc84b97620f5747b597923c71f

robertkirkman avatar Sep 01 '25 04:09 robertkirkman

And I also forgot to say that the portaudio internal source code commit used, here 57aa393109ec996799d3a5846c9ecb0a65b64644, should match the commit of portaudio that the rest of the program is linked to, which in this case is the commit that the portaudio-static package of Termux is built from:

https://github.com/termux/termux-packages/blob/62ccccc8f9bf8b8980bb2047ee5f7c3e9c503a2b/packages/portaudio/build.sh#L9

robertkirkman avatar Sep 01 '25 16:09 robertkirkman