Wednesday 26 August 2020

Using configure scripts to make libraries for iOS

While building a wxWidgets app for iOS, I wanted to build wxWidgets as a library, not include it as part of the application as the minimal iOS example does. The following script (based on ios-autotools) sets up the required environment and then calls the supplied configure script.

    The main changes are:
  1. the configure script is passed as a parameter so that it does not need to be in the same directory as the iconfigure script which keeps the source folder unchanged
  2. if an SDK version is passed in and the SDK for that version of the SDK does not exist then the default SDK is used with the ios-min-version set to the specified version.
#!/bin/sh set -e usage () { echo "Usage: [VARIABLE...] $(basename $0) architecture path" echo "" echo " architecture Target architecture. [armv7|armv7s|arm64|i386|x86_64]" echo " path path to configure script to run" echo "" echo " VARIABLEs are:" echo " SDKVERSION Target a specific SDK version." echo " PREFIX Custom install prefix, useful for local installs." echo " CHOST Configure host, set if not deducable by ARCH." echo " SDK SDK target, set if not deducable by ARCH. [iphoneos|iphonesimulator]" echo "" echo " CFLAGS CPPFLAGS CXXFLAGS LDFLAGS PKG_CONFIG_PATH" echo "" echo " All additional parameters are passed to the configure script." exit 1 } # Sanity checks if [ "$#" -lt 2 ]; then echo "Please supply an architecture name and configure file" usage fi # Build architecture export ARCH=$1 # Configure script CONFIG=$2 # Export supplied CHOST or deduce by ARCH if [ ! -z "$CHOST" ]; then export CHOST else case $ARCH in armv7 | armv7s ) export CHOST=arm-apple-darwin ;; arm64 ) export CHOST=aarch64-apple-darwin ;; i386 | x86_64 ) export CHOST=$ARCH-apple-darwin ;; * ) usage ;; esac fi # Export supplied SDK or deduce by ARCH if [ ! -z "$SDK" ]; then export SDK echo Using supplied SDK of "$SDK" else case $ARCH in armv7 | armv7s | arm64 ) export SDK=iphoneos ;; i386 | x86_64 ) export SDK=iphonesimulator ;; * ) usage ;; esac fi # Export supplied SDKVERSION or use system default if [ ! -z "$SDKVERSION" ]; then SDKNAME=$(basename $(xcrun --sdk $SDK --show-sdk-platform-path) .platform) export SDKVERSION export SDKROOT=$(xcrun --sdk $SDK --show-sdk-platform-path)"/Developer/SDKs/$SDKNAME.$SDKVERSION.sdk" # If the SDK for the supplied version doesn't exist, use the current one if [ ! -d "$SDKROOT" ]; then export SDKROOT=$(xcrun --sdk $SDK --show-sdk-path) # current version fi else export SDKVERSION=$(xcrun --sdk $SDK --show-sdk-version) # current version export SDKROOT=$(xcrun --sdk $SDK --show-sdk-path) # current version fi # Export supplied SDKVERSION or use system default if [ ! -z "$SDKVERSION" ]; then SDKNAME=$(basename $(xcrun --sdk $SDK --show-sdk-platform-path) .platform) export SDKVERSION export SDKROOT=$(xcrun --sdk $SDK --show-sdk-platform-path)"/Developer/SDKs/$SDKNAME.$SDKVERSION.sdk" # If the SDK for the supplied version doesn't exist, use the current one if [ ! -d "$SDKROOT" ]; then export SDKROOT=$(xcrun --sdk $SDK --show-sdk-path) # current version fi else export SDKVERSION=$(xcrun --sdk $SDK --show-sdk-version) # current version export SDKROOT=$(xcrun --sdk $SDK --show-sdk-path) # current version fi # Export supplied PREFIX or use default if [ ! -z "$PREFIX" ]; then export PREFIX else export PREFIX="/opt/$SDK-$SDKVERSION/$ARCH" fi # Binaries export CC=$(xcrun --sdk $SDK --find gcc) export CPP=$(xcrun --sdk $SDK --find gcc)" -E" export CXX=$(xcrun --sdk $SDK --find g++) export LD=$(xcrun --sdk $SDK --find ld) # Flags export CFLAGS="$CFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -mios-version-min=$SDKVERSION" export CPPFLAGS="$CPPFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include -mios-version-min=$SDKVERSION" export CXXFLAGS="$CXXFLAGS -arch $ARCH -isysroot $SDKROOT -I$PREFIX/include" export LDFLAGS="$LDFLAGS -arch $ARCH -isysroot $SDKROOT -L$PREFIX/lib" export PKG_CONFIG_PATH="$PKG_CONFIG_PATH":"$SDKROOT/usr/lib/pkgconfig":"$PREFIX/lib/pkgconfig" echo CFLAGS="$CFLAGS" # Remove script parameters shift 2 # Run configure $CONFIG \ --prefix="$PREFIX" \ --host="$CHOST" \ $@

Sunday 9 August 2020

Issues using wxWidgets on iOS

PNG files fail to load (in the Simulator - not tried a real device yet) using the 'builtin' PNG library

Warning: no bitmap handler for type 50 defined. Warning: CgBI: unhandled critical chunk Error: Couldn't load a PNG image - file is corrupted or not enough memory. Warning: Unknown image data format.

To fix set:

  • Compress PNG Files to NO
  • and
  • Remove Text Metadata From PNG Files to NO

Full screen

Currently wxWidgets doesn't support switching between full screen and non-full screen but I'm working on a patch.

To get fullscreen to work in the current version (3.1.5) you need to set your application to have a lanch screen storyboard and hide the status bar in the setting panel of the target application

Saturday 8 August 2020

EXC_BAD_ACCESS code=50 when launching an iOS Application under the simulator

If you get an EXC_BAD_ACCESS error with code = 50 when running an iOS application under the simulator, disable the hardened runtime for the simulator

Enable Hardened Runtime > Debug > Any iOS Simulator SDK No. The compile options for real devices can be left on Yes.

Monday 3 August 2020

Issues I have run into when building wxWidgets

Generally

  • If the (full?) directory name contains an apostrophe (') you get an error message along the lines of:
    syntax error near unexpected token '(' *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;'"
  • If the (full?) directory name contains a space the build will fail.

For iOS

  • The C and CPP flages -miphoneos-min-version need changing to -mios-min-version.

Monday 13 July 2020

Building GCC for RISC-OS

The instructions at https://www.riscos.info/index.php/Using_GCCSDK are OK but you need to change the URL for the PPL library to https://www.bugseng.com/external/ppl/download/ftp/releases/1.2/ppl-1.2.tar.gz

$ mkdir gccsdk $ cd gccsdk $ svn co svn://svn.riscos.info/gccsdk/trunk/autobuilder/ autobuilder $ svn co svn://svn.riscos.info/gccsdk/trunk/gcc4/ gcc4 $ cd gcc4

Before compiling, you need to edit Makefile and change the PPL URL from

ftp://ftp.cs.unipr.it/pub/ppl/releases/$(PPL_VERSION)/ppl-$(PPL_VERSION).tar.gz

to

https://www.bugseng.com/external/ppl/download/ftp/releases/$(PPL_VERSION)/ppl-$(PPL_VERSION).tar.gz

Once the change has been made you can continue building

$ ./build-world

Once gcc has built (it takes a long time and a few GB of disk space), you're ready to build the packages.

To get autobuilder to compile the packages, you either need rman (I don't know where to get it), or apply the following patch to autobuilder/build

--- build (revision 7339) +++ build (working copy) @@ -76,7 +76,7 @@ popd fi fi - for build_prog in cvs svn wget autoconf automake rman realpath pkg-config doxygen xgettext unzip autoconf2.13 flex bison gperf glib-genmarshal xsltproc intltoolize automake-1.11 ; do + for build_prog in cvs svn wget autoconf automake realpath pkg-config doxygen xgettext unzip autoconf2.13 flex bison gperf glib-genmarshal xsltproc intltoolize automake-1.11 ; do if ! type $build_prog > /dev/null 2>&1 ; then echo "Autobuilder: $build_prog not found; is it installed on your path?" exit 1;

Or you can download my latest version from Git hub. Here you can also find the autobuilder files used to port libpopt and libsmb2 to RISC-OS.

And replace the rman commands in build/env/ro-install (lines 141 and 144 and in some of the packages setvars scripts) with groff -mandoc -Thtml.

Setting up samba as a server for RISC-OS clients

Currently the RISC-OS Lan Manager !OmniClient protocol does not support SMB2 or later protocols.

The following smb.conf file will allow RISC-OS clients to connect using the NT1 (CIFS) protocol. It exports users home folders and configured printers.

# Run 'testparm' to verify the config is correct after you modified it. [global] workgroup = WORKGROUP security = user ntlm auth = ntlmv1-permitted client min protocol = NT1 server min protocol = NT1 passdb backend = tdbsam hosts allow = 192.168.200. printing = cups printcap name = cups load printers = yes cups options = raw [homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes [printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No [print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = @printadmin root force group = @printadmin create mask = 0664 directory mask = 0775

Wednesday 24 June 2020

Running Mac OS Big Sur under Parallels

When I tried to install the developer preview of Mac OS Big Sur in a Parallels VM on my Mid 2012 MacBook Pro, I got the dreaded BIErrorDomain 3 error when I tried to select a target disk.

I googled a lot of places and got lots of sort of answers. I tried creating a clean VM from the Recovery Partition and even that didn't work.

The solution I discovered was to add the following lines to the VMs boot flags.
 (Configuration > Hardware > Advanced Settings > Boot flags:)
devices.mac_hw_model="MacBookPro14,1"
devices.smbios.board_id="Mac-B4831CEBD52A0C4C"
You can also set these by editing the VMs config.pvs file and adding them into the SystemFlags section.
<SystemFlags>devices.mac_hw_model="MacBookPro14,1" devices.smbios.board_id="Mac-B4831CEBD52A0C4C"
</SystemFlags>
With these settings the install proceeded as expected, rebooting a few times along the way.
Unfortunately, it doesn't run very well.