2022-10-10 01:54 pm

Cross-platform Utilities

I'm trying to locate ports of some of the more popular Unix/Linux utilities to other operating systems such as AIX and Windows. I find it helpful to have the same utility on all the systems I work on, not just on a few them.

Are you searching for other programs of this nature or creating other cross-platform utilities of your own? If so, please share your progress. It would be nice to add more options to this list.

cal
http://unicorn.us.com/cal.html

lsof for AIX
https://github.com/aixoss/lsof

top for Unix and AIX systems
https://sourceforge.net/projects/unixtop/

ntop for Windows
https://github.com/gsass1/NTop

lsblk like utility for Windows
https://github.com/tenox7/lsblk

simple cross-platform ping
https://github.com/sryze/ping

ps style tools for Windows
https://github.com/joeattardi/winpstools
https://github.com/katakk/pkill/

uptime
https://github.com/qwercik/uptime

experimental dd implementation for Windows
https://github.com/sryze/wdd

dd for Windows
http://www.chrysocome.net/dd

busybox-w32 has ports of several utilities that will work on Windows including dd, df, grep, ps, su and others:
https://github.com/rmyorston/busybox-w32

nano for Windows
https://github.com/lhmouse/nano-win
I also have a port of nano for Windows. It works with PDCurses.

An older version of htop was patched for AIX support and I've added a similar patch to a later version. When the htop project was contacted regarding patches they responded they were not interested in adding AIX support to the official version.

I have simple cross-platform implementations of uptime, nproc and free which I've been working on.
2022-06-09 08:47 am

WSL and X Windows programs

I've been reading a lot about WSL. It's a great way to run Linux in Windows without needing a virtual machine like VirtualBox or Qemu installed. However, the earlier versions of WSL only ran command line or console based programs. If you wanted to run X Windows programs, you needed an X server. Well it just so happens, I've built the X server on Windows from source and all the packages for it. I've recently been testing remote access to X Windows programs on an AIX machine at work. From those tests, I found X forwarding using tools like putty and a Windows based X Windows server can be rather slow. My experiments with sixel weren't very satisfactory. The other protocols I investigated were vnc and xrdp. Both offer faster alternatives to X forwarding or other techniques I'd tried.

I did not make a lot of progress with the vnc protocol. I was able to build sdl_vnc from source. I had issues with building libvncserver because they're using cmake which never works properly for me. Was able to find an older version that uses GNU autotools and get that working though. Another interesting project is spiritvnc which uses libvncserver and provides a front end using FLTK.
https://sourceforge.net/projects/sdlvnc/
https://sourceforge.net/projects/libvncserver/
Eventually I was able to build two SDL based vnc clients from source code. Unfortunately, there isn't much in the way of documentation and I really couldn't get theTto do much. If anyone finds any decent documentation regarding vnc and either of those clients, please let me know.

Xrdp looked like a very promising option especially when I read that performance was even better than vnc. There isn't an xrdp package for AIX, but there is one for Debian via WSL. So, I decided to investigate. I found several articles on how to set up xrdp for WSL. That was surprising since so many articles I've been reading discussed how hard it was to access WSL based X Windows applications and the need for Microsoft to add GUI support in WSL 2.

It was also surprisingly easy to get working. I used sudo apt-get install xrdp to install it. I added my window manager of choice, jwm, and a few X Windows based test programs, SciTE and tuxmath. The documentation said to add the xrdp user to the ssl-cert group:
sudo adduser xrdp ssl-cert
Then it said to edit /etc/xrdp/xrdp.ini. I did so with nano. I changed any instances of 3389 to 3390. I commented out max_bpp=32 and added nmax_bpp=128. I added nxserverbpp=128 after #xserverbpp=24 which was already commented out. I started the system using:
sudo /etc/init.d/xrdp start
Then, all I had to do was use the remote desktop connection program on Windows and connect using my WSL username and password. When you connect, use computer name: localhost:3390 Everything came up with no issues. I tried out Xfireworks, SciTE and tuxmath. They ran very efficiently considering they weren't running as native Win32 applications. (I also have Windows versions of all these programs.) I was really pleased with the results. I think this method probably works even better for me than upgrading to the latest WSL and using the Microsoft GUI support (which I have tried on one of my computers). Now if I could just get a solution like this working on our AIX system at work, we'd be all set. It would also be interesting to see how this works with Wayland and rdp support in place of xrdp.
2021-11-19 09:14 am

Lightweight Command Line Utility Program Alternatives

I've been investigating some of the lightweight, command line utilities that are often used to check the status on a system. In some cases, it was hard to track down the packages they were in. It's difficult to search when some of the names are so ubiquitous. Just try running a search for the free utility.

I knew that many of the utilities were in the GNU coreutils package. I found out that many others were often supplied by the procps or the newer procps-ng packages. The procps and procps-ng packages are fairly Linux specific. So, it's not likely you'll find the code ported to other operating systems. While GNU coreutils ports to many platforms, I typically prefer GNU alternatives. They tend to be more lightweight with not as many features. Also, many GNU developers don't particularly like programming for portability and often won't accept patches for their code when there are portability issues. Many of the utilities I considered have been on Unix systems for a long time and are also available on BSD systems. The GNU versions tend to add more features and functionality. BSD systems don't use coreutils, so most of the programs are part of the operating system code.

Busybox and Toybox provide a lot of the utilities as well. Both Busybox and Toybox are designed as one monolithic program that can be accessed through links to the various utility names. That's convenient because there can be a lot of repetition between what some of these programs do. Having the code in all in one place means less maintenance for repetitive tasks. In a few cases, more standard versions of some utilities took this approach as well. For instance, the w program on a BSD system is also the who program.

It seems almost random as to what stats some of these programs cover. For instance, uptime not only gives you how long the machine was up, it also gives you how many users are on the system and system load averages. Sometimes seemingly non-related information may all be returned by the same function on a particular operating system, but sometimes it requires different functions to check each statistic. So, why put it together in this particular presentation? Likely, it's just because that's how it's historically been done and changing too much could break a lot of scripts out there. Some lightweight implementations don't always show all the information of the more common versions of the utilities either. For instance, some versions of uptime just show the boot time and don't bother with the other statistics.

Command line options for invoking a program may not be the same for different versions of a program. Also, since many of the programs have been around a long time, the command line options may not be that intuitive. For instance, I typically see -h reserved for help, but in some cases, it's being used for printing a human readable format. Some other utilities use -H for human readable. Some use both lowercase and upper case for human readable but use factors of 1024 bytes for one instance and factors of 1000 for the other. Personally, I would prefer to use -h for help and -B with a blocksize to indicate what factor I might want to divide by. That way you don't need separate command line options for kilobyte, megabyte, gigabyte and kibibyte, mebibyte and gibibtye. Many programs don't even offer options for terabyte which has become much more standard. As memory sizes go up, the older hard-coded options won't adapt as well. As mentioned, one of the issues with changing command line options to make utilities more uniform is that it could interfere with backward compatibility and cause other programs depending on that functionality to fail. However, all the various implementations aren't exactly standardized to begin with. The Open Group has some standards for utility conventions. Many programs use getopt or getopt_long to help standardize parsing of command line. However, it's not enough of a standard to prevent all the differences between different implementations. So, it's not like scripts can rely on all the same options to be there on different platforms or with non-standard software choices anyway.

I was interested in tracking statistics on memory usage, disk space, CPU usage, process and user related information and when a machine was rebooted. The tools I investigated included free and vmstat which show memory usage, df and du for disk space usage, uptime for CPU usage and boot time, nproc shows number of CPUs, ps and top for process information and utilities such as w, who and whoami for user related information.

I wanted to find lightweight alternatives that I could use on multiple platforms and not just Linux. Minix 3 uses a lot of the BSD utilities, so going with those might be one alternative. However, many still have a lot of code to implement them and the code is often very specific to BSD style operating systems.

One place to find lightweight versions of some of these utilities is ubase which was designed with the suckless.org philosophy in mind:
https://git.suckless.org/ubase/files.html
The code is very readable, but can be very Linux specific. Another alternative is nbase:
https://github.com/cheusov/nbase
This is a port of NetBSD tools to POSIX systems so that makes it a more portable option. Earlier versions of Minix had some lightweight versions of various utilities in their commands/simple directory before they switched to the BSD versions. PicoBSD also had some interesting lightweight utilities programs including aps and sps which are ps alternatives and vm which is a vmstat alternative.

There are also Windows ports of utilities such as ntop:
https://github.com/gsass1/NTop However, while some of these programs look like common Unix/Linux/BSD utilities, many are completely rewritten from scratch and would not port well to other operating systems besides Windows. Alternative operating systems such as hobby OSs that some developers create may have some of these utilities as well. After all, they're simple, command line based and useful. However, since many of the hobby OSs don't support POSIX or have large differences in kernel design, their implementations probably don't port well to other platforms either.

I'm currently in need of utilities that work on Linux, AIX and Windows. I've been investigating writing some of these utilities from scratch in a more portable manner so I can use them in a consistent way on whatever operating system I may need them. Unfortunately, they can be difficult to write, since the underlying functions are not part of the C or POSIX standards and are very platform specific. They can even change with the version of the operating system. Nevertheless, I'm going to continue to work on implementing more portable alternatives for some of the more common utilities. They're useful and their functionality is sorely missed on operating systems where they are not native. It would be really interesting to discuss design issues and trade-offs further with any developers who may be working on similar projects or with users testing out these types of utilities.

Would love to compare notes on this subject. Are there other simple command line utilities that I haven't mentioned that you use to check the status of your operating system? Do you know of other alternative implementations for some of the more common utilities mentioned? Are you interested in using some of these utilities on an operating system where they may not be as readily available? Let me know about your experiences in this area.
2021-10-10 09:47 am

Online Social and Group Alternatives

Once again, I'm searching for discussion forums and decent social media options online. I've never been a fan of Facebook, but started using their forums quite a bit in the last year because the forums I used to frequent either disbanded or migrated to Facebook. It can be very hard to find a good discussion forum these days except on major social media platforms. Most social media options are designed similar to blogs. You can have two way conversations, but they're really oriented more for one person sharing something he or she knows. It's much harder to find options that let you ask questions and learn from others.

One of the reasons I'm so eager to find Facebook alternatives is not due to their outages, but due to the fact they seem to be cracking down on censoring posts. I recently posted a recommendation that if someone wanted an alternative to a systemd Linux distribution, he should try the AntiX Linux distribution. I was told I violated their policies with that post. If that violates their policies, I'm not sure at this point what can be worded in a post that won't violate a policy. Also, I joined some of the bereavement groups on Facebook. In some cases, people were posting that they're so depressed they're thinking of things like suicide. I didn't see Facebook do anything about posts like that. I have a bad feeling their monitoring of whether something violates their policies has a lot of automation involved. So, if you use the wrong keywords even though they're being used in a harmless way, an algorithm would flag something like that. However, they don't seem to be catching on to when something is really critical or distressing either.

After the issue with Facebook, Meetup suspended my account. They said I was spamming. I posted to the computer groups I belonged to about a free (as in no charge to anyone interested in attending) event for computer enthusiasts known as Software Freedom Day ( https://www.softwarefreedomday.org/ ). Ironically, I do this every year and have for several years now. My previous annual posts were still visible on Meetup at the time. However, this year, the same information was considered spam and enough of a reason to remove my account with Meetup.

I've been noticing an overall increase in censoring in commercial social media. Ironically, it's not to block what some, including me, might find offensive such as foul language or adult material. It blocks other viewpoints. The censoring also promotes a corporations monetary interests. Why allow promotion of free resources that cost people nothing when a corporation has paying customers who want to promote their own businesses and pay that corporation for the privilege? I've noticed that many people automatically assume that when you share a URL, you're promoting some commercial service and your sending them spam. For years, I've curated lists of free resources on programming and a wide variety of other topics. I am very careful as to the quality, decency and legitimacy of the information I share. It's distressing when someone has an intention of wanting to help others who may be in a similar situation, yet people automatically assume sharing what you know and find helpful is being done for personal gain. The situation is only made worse by the fact that many of the social media corporations are monopolies because people willingly use the service and refuse to make the information they share using that service accessible outside of their chosen social media platform.

One alternative to the more popular social media options out there is to use a distributed system approach such as the Fediverse. The idea of Free and distributed social media is a very good one. The main issue is that they simply don't have as many users as the popular social media sites. Lots of mainstream companies push contacting them through social media forums rather than directly. Some don't even bother with their own web sites. It's frustrating when you want to contact them for tech support and they refer you to their Facebook chat. It's disappointing when they offer you a free gift for buying their product and you find out you need an Instagram account just to access it. Religious institutions often run their services through popular social media sites like Facebook instead of streaming the services on their own sites. Even school districts got on board with using tools like Facebook, Twitter and Youtube. Our local district blocked these sites for a long time. However, they unblocked them after they started using them for communications with the public. Kind of difficult to use a site to disseminate information when you're blocking it internally in your organization. I wish they had chosen better options for communications though. The situation leaves people without Facebook accounts or other popular social media accounts out in the cold. It's really another division in our society between those who have access to popular social media platforms and those who cannot or will not access them. That's just one more unnecessary rift in our society.

archive.org recently shared their WayForward machine which warns about digital freedom and paywalls and censorship. They show a future online with "walled gardens". There's a digital divide but not due to lack of hardware or infrastructure. It's a divide stemming from who is allowed to have access to information. Some might think it's a funny or exaggerated science fiction take on Internet usage showing a possible but unlikely future. However, when I watched, I started crying. As someone in the technical field, I knew the things they were talking about seemed all too real and likely to happen to some extent. You can check it out for yourself here:
https://wayforward.archive.org/
https://wayforward.archive.org/ia2046/

A recent NatickFOSS Linux Users group meeting recommended Mastodon as a Free alternative for social media. The NatickFoss user's groups article introducing Mastodon is available at:
http://runeman.org/articles/natick-foss/mastodon/
I also ran across an introductory article on github:
https://github.com/joyeusenoelle/GuideToMastodon#an-increasingly-less-brief-guide-to-mastodon

As an experiment, I gave Mastodon a try. However, I was disappointed to find, they're just as likely to censor posts as Facebook and Meetup. In this case, the owner of the instance or someone who maintains the instance would have to censor or delete the post. However, it is not uncommon. They also remove users from an instance if they have issues with them. I often enjoy posting about software and I was censored for posting and recommended software that I like to work with because someone maintaining the instance did not like the group that created the software. From a user's standpoint, I really see no difference in Facebook censoring my post because I discussed an alternative to systemd or Mastodon censoring my post because I recommended the programs from sbase as an alternative to GNU core utilities.

Since my first Mastodon try, I did try Misskey and then later gave Mastodon a second try. One's experience with the Fediverse really does depend on what server you join. You can take your profile and posts and move to another server without too much effort. However, finding the right server does make all the difference in whether you'll enjoy the experience or not.

I've always preferred mailing lists for discussions, but after Yahoo Groups went down, there weren't too many options left. Google Groups is still available, but tends to have a lot of spam in many of its groups. I have a list of other mailing list options here:
https://lmemsm.dreamwidth.org/11107.html

A commercial option, DelphiForums https://www.delphiforums.com/, has been around for a very long time. Many of the forums have little or no traffic. However, you can find some wonderful groups there even to this day.

If you're a Linux user, LinuxQuestions.org https://www.linuxquestions.org/ is an interesting forum. They run a poll for best operating systems and best FLOSS software in a variety of categories every year.

I recently stumbled upon a HSP (highly sensitive person) forum:
https://funhsps.forumotion.com/
The posts are very enjoyable. It's just as good, if not better, than any of the HSP forums on Facebook or the commercial HSP forums that you have to pay to join. Unfortunately, it just doesn't get the same amount of traffic as Facebook. Situations like these could be improved if people knew about alternative options like this one and joined in. On the other hand, when groups get too big, they typically aren't as fun anymore. You can easily get lost in the crowd or there may be so many replies that often have nothing to do with an original post or question that you can't find relevant information. So, now is a good time to enjoy some of these lesser known forums.

Other computer and tech related forums and mailing lists I find interesting include:
https://forum.osdev.org/
https://forum.puppylinux.com/
https://suckless.org/community/
https://forum.videohelp.com/
https://forums.tomshardware.com/

There's also Mudcat Cafe which is a wonderful forum for sharing information about folk music:
https://mudcat.org/

I found Lemmy which is a Fediverse link aggregator with communities:
https://lemmy.ml/communities/

Similary to lemmy, there's also kbin:
https://kbin.social/

I'd also like to mention GetTogether https://gettogether.community/
This would make a great free alternative to other social media meeting software or sites like Eventbrite if more people were to use it. You can let people know about your club or group events for free. You can also use free tools like Jitsi for online meetings. I keep hearing people complain that you can't sing as a group online using Zoom. You can with free options such as Jamulus and Sonobus.

Another interesting free alternative for event sites is Mobilizon:
https://joinmobilizon.org/en/
You can find a list of Mobilizon servers with events from around the world here:
https://instances.joinmobilizon.org/instances

Two other Fediverse options for sharing events are Gancio a shared agenda for local communities and Gathio which allwos to make and share events while respecting privacy.
https://gancio.org/instances
https://gath.io/

Also, check web sites such as your local library system and your parks and recreation department for their community events.

If, for whatever reason, you're tired of mainstream social media outlets, check out lesser known options and distributed alternatives. They're less likely to have outages at the same time. You can help promote privacy, freedom of choice and improve handling of censorship and avoid corporate lock-in by using other options for connecting with people. You can also help improve the current situation by letting organizations and companies know directly that you would like other options besides the major social media choices as ways to contact them. Your voice is important. Join in on the conversations in alternative social media outlets and groups and share your knowledge with the world. Please let others know there are alternative options out there. If we work together, we can make these online groups much better than the mainstream options most people choose today.

Know of some great social media alternatives that are being overlooked? Do you have favorites I haven't mentioned? Please post about it and let the rest of us know about it too.
2021-06-29 09:38 am

QEMU Cheat Sheet

I just got used to VirtualBox and ended up having to switch to QEMU. VirtualBox seems to run better than QEMU. I tried to load several operating systems in QEMU that ran fine under VirtualBox and they failed. Decided to try a Debian netinst because that works well with most machines. Then I had to figure out all over again how to get files between the host and guest systems. It's harder to find documentation on what you're looking for with QEMU as compared to VirtualBox.

The first step is to download and install qemu someplace. I'm assuming it's in the path. Otherwise, you need to specify where to run it from.

Next step, create a virtual disk to install the operating system to. The following creates a 2 GB image file in raw format. You can choose other formats.

qemu-img create linuximage.img 2G

I'm using an ISO for 64 bit Linux, so I use qemu-system-x86_64. For 32 bit systems, I can use qemu-system-i386. There are options like qemu-system-i386w.exe which I was wondering about. Turns out these are for use on Windows systems. They prevent bringing up a console when as well as a window when running. However, I typically run everything from the command line, so there's no advantage to this. Windows programs running in console don't create a new console. I recommend sticking with the standard versions without the w especially if you're running from the command line or on a non-Windows system.

I downloaded a Debian netinst ISO and put it in the iso directory. This is the command I used to start QEMU so I could install Debian to the linuximage.img file.

qemu-system-x86_64 -hda linuximage.img -cdrom iso\debian-10.10.0-i386-netinst.iso -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G -boot order=dc -usbdevice tablet

The -m option specifies RAM and I gave it 1 Gigabyte. Once you run the command, hopefully the operating system should boot from the ISO as if it was a CD. You can then proceed to install it to linuximage.img which should appear as the first hard drive on your system. Once the system is installed, you probably want to Power Down and/or Quit QEMU.

Use the following command to boot from the image rather than running from the ISO file.

qemu-system-x86_64 -hda linuximage.img -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G  -boot order=c -usbdevice tablet

The -usbdevice tablet setting seems to help smooth out mouse support which didn't work well without it.

Now comes the hard part, I wanted to move files back and forth from the new system. If the files are fat32 (such as a ReactOS image, you can mount the image and read the files. That doesn't help much with operating systems that use other disk formats. You can load images as floppies or cdroms (typically read only) or add another hard drive. So, the idea was to add a second drive that was formatted using a format the host system could read. I created another image and attempted to format it in using the Guest operating system in a way that the host could read. That failed. I recommend mounting the image and letting the host operating system format it. Then, the guest operating system can be set to access it as a second drive.

To do this on Window, I used a program called ImDisk.
https://sourceforge.net/projects/imdisk-toolkit/
Latest versions of Windows are supposed to allow you to mount an image as well.

I created a new image using:
qemu-img create drive.img 2G

Once I mounted the image using ImDisk, the operating system asked if I wanted to format the image and I let it do the formatting. Then, I could access the image using QEMU. Make sure the drive is not mounted on the host system before using it with the guest system and vice versa.

qemu-system-x86_64 -hda linuximage.img -hdb drive.img -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G  -boot order=c -usbdevice tablet

When I tried formatting the drive using Linux in QEMU, it wanted to access the new drive as /dev/sdb1. When I just use the image created from Windows, it used /dev/sdb.

Once you've created and formatted the extra image, you can access it in your virtual operating system. If you're running Linux virtually, you'll need steps like these.

mkdir -p /mnt/data
mount -o defaults /dev/sdb /mnt/data

They needed to be performed as root or you need to get sudo working properly first. Directory creation only has to be performed once. The mount needs to be done each time you activate the operating system and want to access the image unless you add the information to auto mount it in /etc/fstab. You can also unmount the drive using umount.

Once the drive is mounted, you can move files to and from it. You can see if there's anything on the image using:
ls -l /mnt/data
Copy or move files from /mnt/data or whatever location you mount the drive at as well.

While I couldn't access an image I formatted in the guest system, I did want to go through the steps. It worked fine from within the host and was readable from there.

Install fdisk. Since I'm using fat32, I also needed to install dosfstools. I found the tools in /usr/sbin and had to run from that directory since it wasn't in my path. The commands below assume programs are in the path. They probably need to be run as root or using sudo.

fdisk -l

This shows your images so you can find their names. I set drive.img as -hdb so it shows up as /dev/sdb on a Linux system.

fdisk /dev/sdb

The fdisk program will prompt for further information.

At the fdisk command prompt, I gave it the o option. This creates a new DOS partition. The next command was n to set a partition type. I chose p for primary. I chose the default partition number 1. It brought up first and last sector options and I chose the defaults for both. At the command prompt, I chose t for partition type and gave it a hex code of b which selected W95 FAT32. At the command prompt, I selected w which wrote the changes and exited the program. From the normal command prompt, I ran the following:
mkfs.vfat -F 32 -n WINSTORAGE /dev/sdb1

This should format the image and name the image WINSTORAGE. Windows prefers upper case for disk labels.

Once done I was able to use mkdir to create a directory under /mnt to mount it. In this case it needs to be mounted as /sdb1 not not sdb. The result made an image that worked fine in the guest system but wasn't recognized on the host.

If your host system is a Linux system, it might be helpful to use a more familiar format like ext2 or ext3 instead of fat32. On the other hand, many flash drives use fat32 and most systems can read them, so it might be a useful solution as well. If you create the second image before installing the new operating system, depending on the installation process, it might recognize the extra image and incorporate it automatically. Just make sure not to reformat it when installing the operating system.

The mtools programs can be used on various operating systems and can be used with emulators and images formatted for DOS. Wondering if it could be used to format a mounted image file as fat32 on systems that don't support it natively.

I was also able to successfully create an ISO image on the host system using mkisofs and load that as a virtual CDROM on the guest.

mkisofs is available on Windows with various software. I typically installed DVDStyler and used the program it supplies. Debian and some systems typically don't supply cdrtools which contains mkisofs. Many systems use another package which emulates or gives equivalents to commands cdrtools supplies. GRML is a Debian based distribution that does offer the original cdrtools package. There are some arguments over copyright which kept cdrtools from being added to some distributions. I also found a utility that worked only on Windows that could create ISO files. It was used by some ReactOS developers. Nice thing was that it built easily from source using MinGW.

Assuming my files are in the tmp directory below the directory I'm in, I can run mkisofs with the following command to make an ISO file.
mkisofs -r -R -J -l  -o test.iso tmp

I can add the image using a command like this one.
qemu-system-x86_64 -hda linuximage.img -drive id=cdrom0,file=file,index=1,media=cdrom,file=test.iso -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G  -boot order=c -usbdevice tablet

Once in Linux, the cdrom can be accessed after mounting it with:
mount /media/cdrom

I've used that technique to get Debian to install successfully with QEMU. Haven't had much luck with other systems yet including other versions of Linux. I'd also like to get Androic-x86 or Bliss OS working at some point. XFDOS would be another interesting option to try.

I did finally get ReactOS running in QEMU. Reactos is tricky to load. The Reactos version used must be 0.4.14-RC or higher.

I created an image using the native QEMU format as recommended on the ReactOS site.

qemu-img create -f qcow2 reactOS.qcow2 2G

I installed ReactOS on the image by following the prompts after using this command:

qemu-system-i386 -drive if=ide,index=0,media=disk,file=reactos.qcow2 -drive if=ide,index=2,media=cdrom,file=iso\reactos-bootcd-0.4.15-dev-2847-g0ffbbab-x86-gcc-lin-dbg.iso -m 1G -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -usbdevice tablet -boot order=dc -serial file:reactos.log

Most of the options I picked were defaults.

After the image is formatted and the operating system is installed, power down and/or quit QEMU.

I ran the following command to complete setup after the ISO was no longer accessible from the CDROM drive. It let me set up the system.

qemu-system-i386 -drive if=ide,index=0,media=disk,file=reactos.qcow2 -drive if=ide,index=1,media=disk,file=drive.img -m 1G -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -usbdevice tablet -boot order=dc -serial file:reactos.log

After it's set up as desired, power down and/or quit qemu.

Now, I can run the following command to move files to and from ReactOS within QEMU using the drive.img.

qemu-system-i386 -drive if=ide,index=0,media=disk,file=reactos.qcow2 -drive if=ide,index=1,media=disk,file=drive.img -m 1G -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -usbdevice tablet -serial file:reactos.log

It's accessible as e:. The d: drive is still reserved for the CDROM device.

At one point when I restarted the image, it asked me to press Ctrl-Alt-Delete to get into the system. I found out you can send special keys to QEMU by pressing alt-ctrl-2 to get to a screen where you can enter commands. You can emulate keys using sendkey. I entered sendkey alt-ctrl-delete. Return to the original screen using alt-ctrl-1. This actually accomplished nothing in this case, because the screen was coming due to an error with the system, possibly the registry. I ended up having to reinstall ReactOS to fix it. Sending alt-tab this way once the system was reinstalled worked well.

ReactOS is interesting and can run some great Windows programs. However, it does crash more often than I would like. Can't help thinking a Linux system with Wine would be more stable. There are several themes, but I miss the Windows XP Silver Metallic theme. Supposedly, you can copy the .msstyle file over from a Windows XP machine to ReactOS and it should emulate the style.

Still investigating what other operating systems will run under QEMU and what commands they require.

So, that's my cheat sheet of useful QEMU commands to date. It does seem to have some advantages to VirtualBox, but so far, I haven't been able to run as many operating systems on it. You also have to decipher what to use in the command line or it may fail to run. Once you have the techniques down and the images created, it seems to work well. It seems less complicated to get files in and out than using VirtualBox Guest Additions. Unfortunately, documentation for how to accomplish it is difficult to find.
I'll be interested to see if QEMU will allow access to an extra image when running an Android operating system. VirtualBox Guest Additions typically wasn't an option for most virtual Android based operating systems. Hopefully, that's all that's needed to get a virtual operating system up in QEMU and develop/build applications natively within the guest system.
2020-05-14 11:29 am

Rescue Flash Drive

I am NOT at all happy with Windows 10. I also recommend AGAINST purchasing the Edimax AC 600 WiFi Adapter and a Sandisk flash drive. I've usually felt pretty comfortable using various versions of Windows. However, while working from home, Windows 10 started an update in the middle of an important task I was trying to complete. It then took all night just to update the computer. I turned the system on the next day. It booted up Windows successfully and promptly notified me that there was a problem with the drive and that it would attempt to correct it. After that, I was unable to boot Windows on that computer. In both cases, I was unable to choose not to have the task done to my computer. If Windows 10 had not updated my machine and then attempted to do something to my drive, my computer would still be working right now and I would not have lost what I was working on.

I now find myself in the unenviable position of trying to get back the information I was working on. If anyone has any hints, tips, tutorials on this sort of thing, I'd greatly appreciate hearing about it.

I decided to try to create a rescue flash drive for the system. My first choice was to use AntiX Linux for the operating system because it's lightweight and I'm comfortable with the terminal emulator, rxvt unicode, and one of the window managers, jwm. I have the latest AntiX ISO. My next step was to figure out how to get it on a flash drive. I've seen recommendations for Rufus and UNetBootIn. Rufus wouldn't work on my backup computer. So, I used UNetBootIn. I pointed it to the ISO and told it to save 4000 MB for preserving files across reboots. It asked about modifying a file and not knowing what to do and seeing the recommendation was to select yes, I let it modify the file. When I put the flash drive in my system, I got the error: gfxboot.c32 is not a COM32R image. That left me wondering if maybe I should not have let UNetBootIn modify the file. Reading up on the error, I found I could work around it by typing "live" at the boot prompt. I finally ended up with a working computer again.

My next problem was to get the data files off the system. Several posts recommended using the file manager SpaceFM. I'm typically more comfortable with the command line, but I ended up running SpaceFM & from the command line to see what drives were available and what they were called. The flash drives are installed under /dev and the hard drive is accessible under /media. I can see the c: and d: drives listed with names under /media. I can tell which drives they are based on their size. I was even able to run ls on the d: drive by using /media and the name that showed in SpaceFM. I was unable to access the c: drive. I wanted to copy files off the system, which means I needed another flash drive installed besides the one that held the operating system. I tried inserting a second flash drive, but it was not recognized and did not automount. So, I shut down and rebooted the system. This time I left two flash drives plugged in. When AntiX came up again, I was able to see both flash drives. Now I could copy files from the d: drive to the flash drive. I used the command line to do so. When I was done, I shut down the operating system to make sure that everything flushed properly to the flash drive. I was able to view and access the copied files from the flash drive on another Windows machine.

That still left me with the problem that I could not access the files I really wanted and had not had time to back up (because the system updated in the middle of my work) on the c: drive. I checked some articles on things to try to access the disk. The disk shows as there and the size is right. However, SpaceFM and ls can't see anything on it and give errors when I try to access it. I ran ntfsfix with the drive name (in the format /media/drivename). Luckily, ntfsfix was already available on the AntiX distribution. To avoid using sudo a lot, I did an su to root before running the fixes. Whatever the problem is, it looks like ntfsfix couldn't fix it. So, I'm left wondering what next steps to try and what forensic tools might be available to restore data files on the disk (assuming the Windows update didn't clobber them all, which it may have done).

On top of that, I'm unable to use the computer for any useful tasks at this point. I was hoping if I got AntiX working, I could run it using flash drives instead of the hard drive if necessary. Unfortunately, it seems unable to deal with the wifi hardware. So, another task is to see if I can get wifi working. There's no point in eventually replacing Windows with Linux on the system if Linux can't support the basic hardware like wifi, camera, etc.

I purchased an Edimax AC600 USB WiFi adapter so I could use a different machine to replace the one that failed. When I installed the latest Windows driver that Edimax recommended I use on a Windows machine, it continually crashed my system. I was afraid I would lose yet another computer. I tried it with AntiX Linux and it couldn't recognize the adapter. I also purchased a Sandisk USB flash drive to attempt to back up what I could. When I purchased it, I told the vendor what operating systems I needed to use it with. It would not work with any of my operating systems. I contacted Sandisk and they told me they didn't support it. So the Sandisk flash drive is basically useless hardware that I can't do anything with.

So those are my not so successful attempts at using Windows 10 and Linux on this particular computer.
2020-05-11 10:49 am

FLOSS for Low Resource Computers

Considering how hard it is to get computers (still waiting over a month) and computer parts, now is a great time to look into bringing new life to your old hardware.

While I often see information shared about how Linux brings new life to older computers, my personal experience ( http://www.distasis.com/cpp/slin.htm ) hasn't been as good as some of the glowing articles. When I investigate further, a lot of the successes have been for single purpose servers (typically command line with no desktop support) or single function usage like home theater systems. Many Linux distributions are aimed at the latest hardware and can be just as resource intensive as Windows systems. It's interesting to note that many of the low resource optimizations for Linux originated from the Android project not from the kernel project itself and they are slowly being integrated into the Linux kernel project. Some FLOSS development projects and companies like Google which produces Android don't even want to be bothered with 32 bit systems and want to concentrate on 64 bit only. It can be more efficient to run Linux or other Free operating systems on new minimal hardware like a Raspberry Pi than to try to get something working on an old computer. One can also find systems similar to the Raspberry Pi but supporting X86 so Windows CE and other Windows like software becomes an option. There's even an Android operating system port called Android-X86.

I've often seen Puppy Linux touted as a great system for older computers, but I could never get it to work with my hardware. Slackware is an interesting choice that can be lightweight, but the Lilo boot loader doesn't work for certain types of hard drives and one would need to find a way to independently get grub on those systems. TinyCore Linux is really interesting but it can require a lot of RAM to run properly. Debian has worked on many older systems and there are many great Debian variants. However, even Debian is removing some of their drivers for older hardware. Plus, they've updated to systemd. So, if you want a system you can maintain yourself with minimal dependencies where a package does one thing well per the Unix philosophy, a systemd based OS won't be the way to go.

Some Linux distributions still worth checking out for use with older systems are:
AntiX, a Debian based distribution without systemd
ToriOS, a Debian based distribution catering to older computers
NanoLinux, a TinyCore Linux distribution that uses Nano-X instead of X Windows
Grml, a Debian based distribution, command line, bootable rescue CD

I've also looked into OS options for older computers that were not Linux based. Both FreeBSD and FreeDOS can be more lightweight alternatives than Linux. However, both options typically have less hardware support than Linux. FreeDOS also tends to have more proprietary software and few active Open Source projects available for it. If you're interested in a very lightweight DOS alternative for old hardware, check out the XFDOS project. It offers several Open Source programs for DOS including a lightweight browser.

I've never had any luck with ReactOS. Again, hardware support is an issue. It can run some very complex Windows programs quite well, but it often fails on simple ones I commonly use. While I've recently seen posts that they want to hire development help, I've never found them responsive when I've volunteered to offer my programming skills. Wine seems to be able to run more Windows programs successfully than Reactos and Linux has better hardware support. So, a Linux system with Wine might be a good option for Windows users who want to switch. However, if switching to Linux, I'd personally rather rebuild my Open Source software for Linux rather than try to use it on Wine. I'd love to find some other viable options besides ReactOS. I do remember reading something on the ReactOS forum about a Wine based fork to ReactOS. Haven't been able to find any details though. Some DOS projects mentioned adding partial support for Windows programs using options like HX DOS Extender. However, they only seem to support Win32 console options. I've seen some suggestions of creating a FLOSS OS similar to a Win 3.1 system with a GUI/desktop built on top of a FreeDOS system, but have not been able to find any active projects. Without GUI support for DOS based Windows alternatives, a project like XFDOS using Nano-X seems the best way to go. Nano-X provides basic APIs somewhat compatible with Xlib and Win32 and there's enough support to build FLTK based applications. If anyone finds other viable options in this area, please let me know. I would love to add my programming skills to such a project.

If you have a Windows computer, you can keep running Windows and use FLOSS programs to improve functionality. I've upgraded Windows systems before, but the results are typically sluggish and eventually I end up having to put another operating system on to keep using the machine.
The one thing that seems consistent across platforms is that older versions of operating systems seem to run better on older hardware than newer ones. Developers continue to write software that is more bloated, more complicated and more dependent on other software. Many news sources do not recommend running older operating systems especially Windows. So using older operating systems to keep older hardware alive goes against average advice. If you don't have other options and need to run an older operating system on your hardware, two security concepts to look into are sandboxing and security by obscurity. On Linux systems, Linux containers are a good sandboxing option. You can also try to avoid running as root or admin whenever you access the Internet. You can even disconnect from the Internet completely for security purposes and use options like sneaker net ( http://www.distasis.com/cpp/snet.htm ) to update your systems when needed.

Here are some FLOSS recommendations for low resource or older computers. Some are specifically for Windows or Linux and some are cross-platform portable.


Cross-platform applications:

Web Browser - Netrider
https://sourceforge.net/projects/netrider/

Web Browser - D+
https:/sourceforge.net/projects/dplus-browser/

Web Browser - lynx
https://lynx.invisible-island.net/

Graphics editor - Lodepaint
https://sourceforge.net/projects/lodepaint/

Graphics editor - grafx2
http://grafx2.chez.com/

Command line graphics editor - GraphicsMagick
http://www.graphicsmagick.org/

Command line sound conversion/player - SoX
http://sox.sourceforge.net/

Music player - MilkyTracker
https://milkytracker.titandemo.org/

PDF viewer - MuPDF
https://mupdf.com/

Ebook reader - Bard
https://github.com/festvox/bard
I have a patched version that works better on Windows.

Windows emulator - BoxedWine
https://github.com/danoon2/Boxedwine


DOS Resources:

DOS distribution - XFDOS
https://sourceforge.net/projects/fltk-dos/

DOS emulator - DOSBox
https://www.dosbox.com/


Windows specific and Windows portable versions:

Web browser - Mozilla Firefox, Portable Edition Legacy 52
https://portableapps.com/apps/internet/firefox-portable-legacy-52

Web browser - Chrome Portable
https://portableapps.com/node/60675

Java - Java Portable
https://sourceforge.net/projects/portableapps/files/Java%20Portable/
Install in CommonFiles subdirectory at the same level as where the portable browsers are installed. Java Portable version 8 works on XP and Vista. I've used jPortable_8_Update_66.paf.exe but later versions will probably work as well.

Web browsers - other options
http://rtfreesoft.blogspot.com/
Haven't tried them, but there are several ports of browsers to older hardware.

Web browser - RetroZilla
https://github.com/rn10950/RetroZilla

Web browser - Supermium
https://github.com/win32ss/supermium

IM - Miranda NG
https://github.com/miranda-ng/miranda-ng

Sandox - Sandboxie
https://github.com/sandboxie-plus/Sandboxie
https://www.sandboxie.com/GettingStarted

Firewall - Simplewall
https://github.com/henrypp/simplewall

Host-based Intrusion Detection System - ossec
https://github.com/ossec/ossec-hids

PDF viewer - SumatraPDF
https://www.sumatrapdfreader.org/free-pdf-reader.html

Image editor - I.mage
http://www.memecode.com/image/

ISO access - WinCDEmu
https://portableapps.com/apps/utilities/wincdemu-portable
If you can't find a copy of WinXP Virtual CD Control Panel for accessing ISO files or it doesn't work on your system, you can try WinCDEmu.

CD and DVD creation - rktools
https://www.microsoft.com/en-us/download/details.aspx?id=17657
This isn't FLOSS, but it's very useful for creating CDs and DVDs from the command line.

GWBasic
https://github.com/microsoft/GW-BASIC
The original source code of Microsoft GW-BASIC from 1983 is available under a MIT license.


Linux/POSIX software:

Window manager - JWM
https://joewing.net/projects/jwm/

Terminal software - urxvt
http://software.schmorp.de/pkg/rxvt-unicode.html


If you have other alternatives (operating systems or FLOSS software) that work on older hardware that you'd like to recommend, please let me know ( http://www.distasis.com/connect.htm ). I would love to find some other options. I'm also actively looking for operating system projects that need (and actually want) volunteers to help port lightweight software to them. Would be interested in hearing how others are coping with keeping older hardware alive. Hope you'll share your own articles, blogs, projects with everyone.
2019-05-09 09:59 am

FLOSS Educational Distribution - Ideas Needed

For a long time now, I've been wanting to put together an ISO with Free, Libre and Open Source software similar to the kind our Linux Users Group gave out on Software Freedom Day. I'd like to gear it specifically toward educational software so that groups like Schoolforge may make use of it. If you'd like to help, I would love to have suggestions for lightweight, portable software that can run in console or framebuffer mode. I'm specifically interested in educational, hobby-related, utility, information/organizing and/or word processing programs. Have any recommendations? Please let me know ( http://www.distasis.com/connect.htm ).

Since I'm creating this to promote FLOSS software, I thought it would be great if I could distribute the software on a remastered Linux ISO that could be run from VirtualBox or Qemu or that might boot from a DVD or flash drive. I'd like to try to stick with a console based distribution so that it's lightweight and runs well on older computers with low resources. That means all programs need to be command line, console based (ncurses/pdcurses) or work in framebuffer mode (using SDL 1.x, nano-x, nx11, FLTK, etc.) in order to run on the system without X Windows or Wayland. For efficiency, I'd prefer compiled programs (such as those written in C) to ones that require an interpreter to run. I'd also like to make it as accessible as possible as far as internationalization and for users that may have disabilities. I'm using internationalized language support when possible via gettext. There are utilities like flite and espeak for text-to-speech support. My goal is to put together a lightweight, low resource distribution that will work well for users with older computers and users with no or limited Internet access. There are plenty of things you can do with a computer even if you can't get access to the Internet. Why not make some of those options more readily available?

I'll list some of the software I'm currently considering for the distribution. I'm still missing functionality in several areas, so if you have any recommendations for programs that would fit the criteria I've mentioned, please let me know.


Graphics applications

grafx2 - graphics editor
lodepaint - graphics editor
graphicsmagick - command line graphics editor
picaxo - graphics viewer
perigee slideshow - slideshow viewer
gifsicle - command line tool to create animated GIF files
GLE - command line tool to produce charts
nanosvg - includes lightweight SVG viewer


Music creation/audio applications

I'm still looking for a good Karaoke program (written in C or C++). TiMidity++ does some lyrics display, but I've yet to see it display lyrics created by abc2midi using the console version of TiMidity++. Some educators have found Karaoke to be a good way to help students improve their reading skills.

abc2midi - create your own music using music notation and convert to midi format (command line)
abcm2ps - creates sheet music (command line)
sox - sound exchange, audio file converter and player (command line)
milkytracker - create and play music
TiMidity++ - plays midi files


Readers

Still need several suggestions in this area. I'm currently looking for lightweight PDF and Postscript viewers. Was thinking of using mupdf but I'd still need a decent front-end for it that will work in framebuffer mode. Xpost might make an interesting alternative for Postscript display, but it's still in the works. I found a cbr/cbz library, but don't have a good framebuffer based front end for that yet either. It could be integrated with mupdf or used standalone. Would be nice to include some educational public domain ebooks with the distribution too.

bard - epub reader with text-to-speech capability
pdftxt - converts PDF to text using libmupdf (Can be used with search tools such as grep.)
qpdf - command line PDF transformation tool
sdlbook - SDL front end for libmupdf (Recently found this and it may fill my needs for a PDF viewer.)


Audio/video players

flxplay - plays flx movies
theoraplay - plays ogg theora videos and ogg vorbis


Astronomy

nightsky - displays stars
pngphoon - graphically shows moon phase (command line)
lcal - command line based lunar calendar that outputs to PostScript


Word processing

I'm thinking of using one or more of the following editors as an alternative to the popular vi/vim and emacs editors. Other suggestions welcome.

nano - ncurses/pdcurses editor
textadept - programming editor that uses scintilla editor widget has ncurses/pdcurses front-end
wordgrinder - ncurses word processor
mp (maximum profit) - editor with ncurses/pdcurses front-end


Other text related utilities

I have a few dictionaries in stardict format that are Open Source. (Created one from the Mobi project.) I'm looking for other Open Source dictionaries in the stardict format or easily converted to that format. Also still looking for a good grammar checker program.

hunspell - command line spell checker
sdcv - command line version of stardict dictionary tool
style - readability tool
diction - readability tool


Information managers/organizational tools

This section needs some additions. Anyone know a good SDL based calculator? I'd love to find a decent command line utility to avoid repetitive stress injury. There are some great desktop ones such as (workrave and prevrsi).

pcal - command line calendar that outputs to PostScript
ckpass - possible command line keepass replacement
sc - spreadsheet calculator


Hobby related

Don't have much in this category yet. There are several good HAM radio programs available. Maybe some of them that will work in console or command line mode could be added. Other hobby suggestions welcome. Also, maybe some public domain ebooks on hobbies could be useful.

nut - nutritional analysis


Educational entertainment

If you have other recommendations, please let me know.

lpairs - memory game
dual-n-back - memory tool
anagramarama - anagram language game
scramble - anagram language game
hangman - language game
concentration - memory game
tuxmath - game for improving math skills
starlanes - interstellar commerce game


That's all I have so far. I still have to look into remastering a Linux distribution. If you have tips for a simple remastering tool to use or know of some good documentation on how to remaster a Linux distribution via command line, please let me know. Would also appreciate other suggestions for lightweight, portable, useful or educational software (preferably in C). I'm also looking for Creative Commons, public domain or Open licensed educational media (ebooks, videos, etc.). Know of a Linux distribution that's already doing a similar project and would like another volunteer? Please let me know. If you'd like to discuss this project further or help out in some way, feel free to contact me ( http://www.distasis.com/connect.htm ). Thanks.
2019-02-20 09:57 am

GUI library design

Some of the C graphics libraries are great, but I've yet to find a simple GUI that makes it easy to port some older BASIC programs that I want to be able to keep working with. I've created several iterations of my own GUI library, but have never been satisfied with the results. That's the main reason I keep investigating cross-platform GUIs, to see if someone's found a better way to do it. Of the various designs, the ideas behind the immediate mode GUIs seem the most useful for the type of programs I'm targeting. However, I can't seem to find one GUI library that provides a simple way to do what I want. So, I've decided to revisit my old GUI library designs but eliminate some of the framework constraints and some of the object oriented elements. Instead, I'm looking at a more procedural approach that uses concepts from immediate mode GUIs.

Even though I'm avoiding popular C/C++ GUI libraries, I'm not starting completely from scratch and writing everything myself. There are plenty of good graphics libraries that are very portable and make a great basic starting point for a GUI. One of the libraries I've been very impressed with is SDL. It makes a great base for porting software. I've also done a lot of work with PicoGL (a TinyGL fork). It's a convenient way to make OpenGL more portable and avoid some of the version issues. It works on low resource platforms such as handheld devices that don't have high performance video driver support. I've often found OpenGL and Mesa slow on older computers and low resource systems. PicoGL provides very good performance on these types of systems. While using Win32 is not as portable as I would like, it's not that hard to get an OpenGL window up and running on Win32. That easily allows switching between Win32/OpenGL and SDL (1.2.15 or SDL 2.x)/PicoGL. SDL can work on a variety of platforms and PicoGL can work with SDL or with other options such as nano-x, X11 or vesa framebuffer. It shouldn't be too hard to take the output from PicoGL to use with the Android bitmap API either. Another possible option for a backend is Allegro. Like SDL, it works on a variety of platforms. It would be nice to switch between SDL and Allegro as backends depending on which works best for a particular platform without needing to redesign an entire application.

The PDCurses/ncurses API provides a standard way to create console based programs that work well on a variety of platforms from DOS to Windows to FreeBSD to Linux. However, it provides only text support and no real graphics support. While it's great for porting programs written to work with it, I don't think it's the best option to use as a GUI backend. I recently came across TinyCurses which provides a subset of the API and uses SDL as a backend. PDCurses also offers SDL as a backend option. I couldn't help thinking, once a decent GUI design was finalized, it wouldn't be too hard to provide a subset of functionality similar to PDCurses/ncurses. That would allow for easy porting of some PDCurses/ncurses based applications to any platform the GUI library works on.

So, why not just use OpenGL as the backend to design a GUI library? After considering the pros and cons, I decided I don't want to be tied specifically to OpenGL as an API for 2D graphics. While it's very popular and available on several platforms, the changes from a fixed function pipeline to a programmable pipeline with its own shading language make it hard to port programs from one version to another. PicoGL makes use of old fixed function pipeline concepts. Windows OpenGL also uses the older design. Mobile devices and WebGL make use of the newer concepts and the ability to harness the GPU to do more processing. Many developers seem to be abandoning the older concepts and embracing the new programmable pipeline design. However, that leaves some nice older applications that were designed for earlier versions of OpenGL that won't port easily to the newer versions. They might require a complete redesign and rewrite. Using PicoGL is one way to make it easier to port such applications. It can do software rendering to a bitmap which can then use more modern methods (including later versions of OpenGL or SDL 2.x) to transfer the bitmap to the screen. While the idea of using OpenGL as the portable backend for a GUI library sounds good, dealing with version differences and what versions may be available on which platforms does not make it the best option for a complete cross-platform portable solution. Instead, I prefer the concept of being able to switch out backends to use what works well on a particular platform. The GUI library should encapsulate the rendering as much as possible to avoid needing to rewrite applications in order to switch to another backend.

On the other hand, many GUI libraries and some other rendering libraries (such as SDL) offer ways to interoperate with a graphics library like OpenGL. While I want my GUI library code to be cross-platform, I don't want to limit a developer to using just that API. If a programmer wants to use OpenGL or SDL2_gfx or some other library to handle 2D/3D graphics, I'd like the GUI to be able to interoperate with that choice. It would mean that the resulting application would be less portable. However, if an application is already designed to utilize SDL2_gfx, OpenGL or some other library that could work compatibly with the GUI library, it could make adding some GUI functionality to an existing application much easier.

I definitely know what I'm looking for in a cross-platform GUI. I want a simple, portable way to get text, menus, forms, file/directory picker dialog functionality to the screen. I'd like to make use of Freetype fonts. I want an internationalized way to display text and for users to input text. The text strings will probably involve a library such as gettext. I want the options to use keyboard input for those of us who prefer keyboard commands to get their work done and mouse/touchscreen input for devices such as mobile phones where a real keyboard may not be available. I need to be able to access graphics and audio information from a file system or from a zipped file (such as .apk file on Android). I don't care if the look and feel matches what's in style for a particular device or operating system. I just want it to be user-friendly and ergonomically designed.

If you're interested in GUI design or working on a GUI or gaming library of your own, I'd love to compare notes on the subject. Have an idea for what C library might make a good backend for a portable, cross-platform C based GUI? Let me know. Feel free to discuss design issues or other C/C++ topics on the CppDesign mailing list or contact me to compare design notes and share ideas ( http://www.distasis.com/connect.htm ).
2017-05-15 11:10 am

C runtime libraries

Was at a PHP meetup where the group was discussing Docker. Members and the presenter knew certain Linux distributions had a smaller footprint for use with Docker. I was surprised to find out they really didn't know why that was. One of the key factors is the C runtime library. Basic C runtime libraries just cover the functions and data structures that are part of the ISO C standard. Many C runtime libraries also add functions and data structures that are part of the POSIX standard as documented by the Open Group. Some C runtime libraries are rather bloated and provide a wide variety of functions (even beyond those documented by the ISO C and POSIX standards). Others provide a bare minimum. Some, especially those targeting embedded systems are designed for efficiency. Others are designed for functionality. Some provide no Unicode support (locale 'C' only). Some like musl, concentrate on UTF-8 support. Some try to support a large variety of characters sets and internationalization features. All these factors can affect code size and efficiency when compiling programs.

Alpine Linux previously used the uclibc runtime library and now uses the musl library. Most major Linux distributions use glibc. It was a big step, but a positive one when Debian (and Ubuntu) made the switch to eglibc. The choice of C runtime library can make a huge difference for the operating system.

For Windows developers, if you're using MinGW, the GNU compiler on Windows, you're using the Microsoft runtime libraries. The original version of MinGW used crtdll.dll but later versions use msvcrt.dll. Windows systems typically have one of these runtime libraries already installed. So while, you can't distribute Microsoft's libraries, you really don't have to. At least one is already on any particular Windows system. It gets even more complicated because different versions of Windows have different versions of msvcrt (such as msvcr70.dll, msvcr80.dll). MinGW uses a subset of the runtime functions based on Visual Studio 6.0. There are ways to access runtime functions from later versions of Visual Studio, but the application becomes less portable to various versions of Windows. Cygwin which also works on Windows, avoids the problem of dealing with multiple Windows runtime libraries and dlls and provides better POSIX compatibility for their runtime library by using a runtime library based on newlib.

There are a wide variety of runtime libraries designed for embedded systems. They're typical more compact and less bloated than a library like glibc and many are easier to port to various platforms. Of the runtime libraries available for embedded systems that are highly portable, I thought the newlib design was interesting. newlib is currently maintained by Red Hat. There are a limited number of syscalls (typically functionality provided by the kernel) that one needs to provide code for to get the library to work. Newlib uses a combination of public domain and BSD style licenses. Cygwin uses a runtime library derived from newlib, but adds several POSIX functions. It also uses a GNU GPL license. That means whenever you distribute programs linked with their runtime library you must also distribute the source code in order to be compliant with the GPL license.

As mentioned, the standard C library on most Linux distributions is glibc which was developed by the Free Software Foundation. The glibc project was slow to take patches and is a rather large library, so some distributions switched to eglibc which is binary compatible with glibc. The binary compatibility makes it easy to switch between the two. Some Linux distributions wanted to avoid bloated C libraries and work well on low resource or older systems. They chose uclibc which was designed for embedded systems. When I worked with a uclibc based distribution, I found myself making several patches to Open Source programs just to get them to compile. Many Linux distributions such as Alpine Linux are now using musl. It's designed for efficiency and standards compliance including full POSIX standards compliance.

musl was designed to work with a Linux kernel. So unlike choices such as newlib, it is not easy to port to other operating systems. The midipix project is endeavoring to create a POSIX compatible layer for Windows, so that musl will work out of the box on that system. Musl uses a MIT license. The midipix project will use a more restrictive license similar to Cygwin. Many basic embedded system libraries tend to use less restrictive licenses like MIT and BSD so that they will be adopted by companies. However, project or company adapts a C library to a particular system and adds a lot of functionality, they typically tend to use GNU GPL or other more restrictive licenses. Many projects dual license in hopes of selling companies a commercial license with less restrictions.

Google developed the Bionic C library for it's Android operating systems. It has a BSD license. It's also designed to work on low resource systems so it tends to offer less functionality than other C libraries such as glibc. It has partial POSIX support.

I've been hitting many limitations with the MinGW runtime libraries when it comes to porting. Alternatives such as Cygwin's or midipix's runtime libraries would overcome the issues. However, the licenses are much more restrictive. I know I definitely wanted more POSIX compatibility on Windows than MinGW offers out of the box. As a cross-platform programmer, it would be nice to take whatever C runtime library I end up with on Windows and reuse it on Linux and other systems. I looked at C runtime libraries for embedded systems which typically port well. Of those, newlib seemed the most interesting, because according to some of the documentation it only requires 17 syscalls to port it to an operating system. Some Windows CE compiler ports use newlib with added functionality for the Windows CE operating system to derive a working C/C++ compiler. When I investigated the newlib code, I did not particularly like the design, especially the way it handled threading by providing standard and threaded versions of functions. The implementation of file I/O looked like it had been modified several times and at this point could use a major refactoring. When I read some of the comments in that section of the code, I felt very uncomfortable using the library. I wanted a simple, clean, basic design that I can add to.

Another option I looked at was PDClib. I love the idea of a public domain library. MinGW original licensed their WIN32 and runtime code (which integrates with Microsoft's code) as public domain.
PDCLib was based on an earlier Public Domain library project originally at Sourceforge. I tried PDClib on Windows (which the developer says he uses it with), but I was unable to get file I/O to work properly. I contacted the developer to see if he needed with the project, but he really didn't seem to need any assistance at the time. PDClib only supports standard C functions. It does not provide any POSIX functionality. So, it would have limited usage as is for running most Open Source programs.

A number of original operating systems use their own C runtime libraries. I figure, if they can reinvent the wheel and create a C runtime library for their particular purposes, so can I.

I've been coding functions that are typically part of the C runtime library in order to provide better porting support for Windows. I wrote a C11 compatible thread library, several BSD and POSIX string functions, some POSIX file functions, etc. That left me with the dilemma of how best to integrate the additions with the runtime library. They really should be part of the library and part of the C standard headers. I currently have them implemented as supplemental libraries that have to be added separately. It's easier to test and integrate on various operating systems that way. Ideally, it would be nice to have everything accessible as one library though.

I'm very familiar in the various methods of connecting to the kernel in Windows. Some projects such as midipix just use ntdll.dll. Other projects connect to other Microsoft dlls such as kernel32.dll. One can use LoadLibrary, GetProcAddress to connect t a dll or if the library is already linked in, one can skip LoadLibrary. A few Open Source projects I've seen actually implement the LoadLibrary functionality from scratch. I'm not as familiar with the techniques to connect to the Linux, BSD and other kernels and would love to find more clear documentation on this subject. If you run across any good materials, please let me know ( http://www.distasis.com/connect.htm ). Linux uses techniques such as vdso, vsyscall, syscall to call kernel functions.

I find it fascinating to consider the design trade-offs of various C runtime libraries. With that in mind, here's a list of some of the C runtime library options:

eglibc:
http://www.eglibc.org/home
uclibc:
https://www.uclibc.org/
musl:
https://www.musl-libc.org/

Linux from Scratch build instructions (including musl)
http://clfs.org/view/clfs-embedded/arm/
midipix
http://midipix.org/
BSD regular expression library
(Musl regular expression support was forked from this library.)
https://github.com/laurikari/tre

PDCLib:
http://pdclib.e43.eu/
Original Public Domain C library:
https://sourceforge.net/projects/pdclib/
https://sourceforge.net/projects/pdos/
Another fork of PDCLib:
https://github.com/DevSolar/pdclib
libTom Public Domain libraries for math and cryptographics functions
(Some of musl's functions were forked from these.)
http://www.libtom.net/
libc11:
https://github.com/dryc/libc11
Eltanin-OS simia:
https://github.com/eltanin-os/simia

Bionic:
https://github.com/android/platform_bionic

Newlib:
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=tree
libgw32c:
http://gnuwin32.sourceforge.net/packages/libgw32c.htm

Windows CE cross-compiler:
http://cegcc.sourceforge.net/
https://sourceforge.net/p/cegcc/code/HEAD/tree/

ELKS
https://github.com/jbruchon/elks

FUZIX
https://github.com/EtchedPixels/FUZIX

lib43:
https://github.com/lunixbochs/lib43

Embedded Artistry's libc:
https://github.com/embeddedartistry/libc

GNO
https://github.com/GnoConsortium/gno

Sortix C library:
https://gitlab.com/sortix/sortix/blob/master/libc/

MentOS:
https://github.com/mentos-team/MentOS/tree/master/libc/src

olibc:
https://github.com/olibc/olibc

CloudABI's standard C library:
https://github.com/NuxiNL/cloudlibc/

cc65 - C for 6502 systems:
https://github.com/cc65/cc65

kLIBC fork for OS/2:
https://github.com/bitwiseworks/libc

clib2 for Amiga
https://github.com/adtools/clib2

welibc:
https://bitbucket.org/wrelam/welibc/src/master/