The
setup-wsl GitHub Action
can setup a WSLv1 or WSLv2 environment in Windows GitHub Actions runners.
This allows testing certain quirks and corner cases one might encounter when running software on Windows Subsystem for Linux.
Matlab cross-platform capabilities involve cross-platform factors dealing with filesystem and system calls.
The standard library for Matlab
matlab-stdlib
provides several features on top of factory Matlab.
Filesystem functions including
canonicalized paths,
finding executable programs,
and retrieving
filesystem type
are among key capabilities of Matlab-stdlib.
Matlab R2025a makes public the internal functionality introduced in Matlab R2024b.
The
filePermissions
function returns an object like
matlab.io.UnixPermissions
according to the operating platform.
As this functionality and classes are officially released, Matlab-stdlib is planned to incorporate them for new-enough Matlab releases, while continuing to work for older Matlab releases–currently back to R2019b.
Needless use of administrator “sudo” privileges during install of a library or program is generally undesirable.
Admin / superuser privileges are typically invoked for a single command by
sudo,
including on
Windows.
Casual use of “sudo” can goof up the operating system itself, create cybersecurity risks, and mess up the desired program installation.
The install might do undesirable things like put itself under “/root” directory or make paths non-readable by the non-privileged user.
In general we write procedures without invoking sudo, to avoid careless sudo invocation.
We assume the user knows when it’s appropriate to invoke sudo.
sudo is commonly used with commands installing from repositories like “apt install”.
Python “pip install”
defaults
to
PEP 370--user
if needed.
In general, don’t install with sudo pip or sudo conda to avoid wrecking the system configuration.
Computing platforms may have multiple version of the HDF5 library installed.
The HDF5 library version currently being used can be determined by the program as in the following examples by language.
The HDF5 library can write backward-compatible HDF5 files by
HDF5 version bounds.
At the time of writing, there is no way to introspect the HDF5 library version required to read a specific HDF5 file.
Static linking of the executable compiler / libc / system libraries can help mitigate missing library issues.
Dynamically / shared linked executables on Windows require the DLL path to be in the environment variable PATH or the executable directory.
On Linux / BSD, the shared library path must be in the environment variable LD_LIBRARY_PATH.
On macOS, the shared library path must be in the environment variable LIBRARY_PATH.
If the developer switches compiler environments, or the end user is missing compiler libraries, the executable may fail to run due unresolved dynamic library path.
Relatively few Windows users have compilers installed.
Missing DLLs and DLL Hell are part of distributing Windows programs, where batch scripts can be used to set environment variables and Path for the program.
A typical error code for missing DLL is -1073741515 → 0xc0000135 STATUS_DLL_NOT_FOUND.
Simply specifying static compiler linking flags does not guarantee portable executables, which are a more
general problem.
Even using a slim libc like
musl
doesn’t generally
work for graphical programs
using X11 / Wayland.
The
Cosmopolitan
project creates a single binary executable from C/C++ code that works across operating systems.
GCC / Gfortran can statically link compiler libraries including libgfortran into the final executable using flags
-static
and
-static-libgfortran
This increases the size of the executable, which may be negligible compared to the nuisances avoided.
For special cases where the system libc and libc++ aren’t used, the compilers typically have additional flags like -static-libgcc and -static-libstdc++.
Some libraries may only be available as dynamic, and the options above typically will use the dynamic version if static isn’t available.
macOS static linked executable may only work on your specific computer; macOS prefers dynamic linking.
In general, we use the default build system linking (dynamic or static) unless there is a reason to specify static linking.
GitHub
Gists
give good visibility in search engines and GitHub Search.
Gists integrate well using site generators including
Hugo.
However, GitHub Gists do not support GitHub Actions, Discussions, etc.
Gists also do not allow directory structure.
Once a Gist reaches a certain feature level or number of files, it may be more useful to share the content as a GitHub Repository.
Simply import the Gist URL to a new Repository.
Once satisfied with the imported Repository, the Gist can be deleted, or leave a simple note with Repository URL.
An advantage of importing rather than just copying the files over is the Gist history is preserved as Git commits.
If Git was used to manage the Gist, commit messages are preserved.
Edits made to the Gist in the web editor don’t have commit messages.
CMake
check_source_runs
and Meson
compiler.run
check if source code compiles, links, and runs correctly.
If the checked program uses shared libraries (DLLs) such as libstdc++ on Windows, the program may fail to run due to conflicting DLLs in the Path environment variable.
In
CMakeConfigureLog.yaml
or meson-logs/meson-log.txt,
the error code may be
0xc0000139 STATUS_ENTRYPOINT_NOT_FOUND or 3221225785
corresponding to a conflicting DLL.
Error code
0xc0000135 STATUS_DLL_NOT_FOUND
corresponds to a missing DLL.
The general solution is to avoid unnecessary paths in the Path environment variable.
Ensure the compiler and runtime library path are in the Path environment variable before conflicting DLL paths.
Check if libstdc++ has multiple entries in the Path, particularly before the compiler and runtime libraries DLL directory.
From Terminal:
where.exe libstdc++*.dll
If this prints
INFO: Could not find files for the given pattern(s).
then the libstdc++ DLL is not in the Path, which may result in error code 0xc0000135.
If the libstdc++ DLL is in the Path, check if it is in multiple locations.
The ideal is to have one path result.
At least the desired compiler/library path must be the first result.
For example,
Meld
is a program that causes DLL conflicts if put on the Path.
Examples of using small PowerShell scripts for
GCC
and
Clang.
REPL
and other command line programs can catch Ctrl+D EOF in Java in a platform-independent way.
Assuming
java.util.Scanner
is used to read input from the command line, the code for Ctrl+D EOF detection works by catching EOF by scanner.hasNextLine() method, and also catches
Ctrl+D EOF
by checking for Unicode character \u0004 in stdin pipe.
import java.util.Scanner;
publicclassMyClass {
publicstaticvoidmain(String[] args) {
Scanner scanner =new Scanner(System.in);
String argument ="";
final String prompt ="MyREPL> ";
System.out.print(prompt);
while (scanner.hasNextLine()) {
String input = scanner.nextLine();
String[] inputArray = input.split(" ");
String command = inputArray[0];
if (inputArray.length> 1) {
argument = inputArray[1];
} else {
argument ="";
}
if (command.equals("exit") || command.equals("\u0004")) {
break;
}
// main program logic here }
}
}
Windows can control WiFi from the Command Prompt, including WiFi AP preference order.
Via the Windows WiFi settings GUI page, the latest added WiFi pushes to the top of the preference stack.
This is typically not desired, as when setting up a device in general, one usually connects to the most needed WiFi AP first, and over time adds temporary or less desired WiFi, which Windows keeps at the top of the WiFi preference list.
This
netsh
command prompt procedure allows correcting the Windows WiFi preference order.
This command lists the known (previously connected) WiFi AP, just like shown in the Windows WiFi settings GUI:
netsh wlan show profiles
The WiFi AP are listed in preference order, from most preferred at the top to least preferred at the bottom.
A key piece of information needed from this command is:
Profiles on interface “Wi-Fi”
The name might be “Wi-Fi 2” or other if multiple WiFi adapters are in the PC.