Build wc3270 from Source
under IBM i/PASE/IBM OSS
This second version maximizes the use of IBM i open-source software dependencies rather than mixing PASE and open-source libraries. The previous hybrid approach compiled successfully but did not behave reliably at runtime.
✦Goal & Limitations
- Enable screen scraping on IBM i partitions via Python. This requires the wc3270 suite of emulators as an underlying dependency.
- The p5250 and p3270 python modules are needed to achieve this. They rely on the wc3270 software suite.
- The
x3270(GUI) emulator is not supported. - DBCS characters are not supported — likely because this was compiled on a non-DBCS machine.
✦Prerequisites
- Use an SSH session with bash as the active shell:
/QOpenSys/pkgs/bin/chsh -s /QOpenSys/pkgs/bin/bash - Verify your
PATHincludes the required directories:
echo $PATH
/QOpenSys/pkgs/bin:/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
Download and extract suite3270-4.5ga5-src.tgz into ~/wc3270.
Apply the patch to the source tree before building.
⬇ full_diff.good5.patch See Annex A2 for procedure ↗Download and check the required open-source packages list:
⬇ packages_intalled_list_for_compilation_wc3270-20260405.txt1Environment Variables
CFLAGS environment variable needs to be exported before configure in this version. All compiler flags are passed directly to the configure command.
2Configure
2.1 — Configure command
Run the single configure command below. It explicitly disables missing PASE functions via ac_cv_func_* cache variables and links against open-source ncurses and readline from /QOpenSys/pkgs:
\\\) in LESSPATH and MOREPATH are intentional — the shell consumes two levels of escaping, leaving one literal \ in the final compiled string value.
./configure \
--disable-x3270 \
--prefix=/QOpenSys/pkgs \
AR="ar -X64" \
RANLIB="ranlib -X64" \
ac_cv_func_asprintf=no \
ac_cv_func_vasprintf=no \
ac_cv_func_strcasestr=no \
ac_cv_header_ncurses_h=yes \
CPPFLAGS="-I/QOpenSys/pkgs/include -I/QOpenSys/pkgs/include/ncurses" \
CFLAGS="-maix64 -O2 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE -D__EXTENSIONS__ -DLESSPATH=\\\"/QOpenSys/pkgs/bin/less\\\" -DMOREPATH=\\\"/QOpenSys/pkgs/bin/more\\\"" \
LDFLAGS="-maix64 -L/QOpenSys/pkgs/lib -Wl,-blibpath:/QOpenSys/pkgs/lib:/usr/lib -liconv -lutil -lncurses -lreadline"
2.2 — Build Patch for Missing PASE Functions
Some functions are absent from the PASE libc. Compile them manually from the Common/ subtree. Position yourself at the build root first:
cp lib/include/unix/conf.h include/conf.h
cd Common
gcc -maix64 -I../include -c asprintf.c -o asprintf.o
gcc -maix64 -I../include -c ft_strcasestr.c -o ft_strcasestr.o
3Make
Run the make command:
make
ar: No such file or directory error on asprintf.o. This is a known race condition in the build system. Simply re-run the exact same make command; it will complete successfully.
Try up to 3–4 times if needed. Compilation warnings on the second run are harmless.
Example of the transient error (first run):
Immediately re-run — this time it should finish cleanly:
make
4Install
Stage the installation into a temporary directory for inspection and later RPM packaging:
mkdir /tmp/wc3270-package
export DESTDIR=/tmp/wc3270-package/
make DESTDIR=$DESTDIR install
After a successful install, verify the binaries under the staged tree:
5Build RPM Archive
Create the rpmbuild directory tree
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
Create & populate the SPEC file
nano ~/rpmbuild/SPECS/wc3270.spec
Name: wc3270
Version: 4.5
Release: 1
Summary: Console and GUI 3270 emulator for IBM i
License: BSD
Group: Applications/Emulators
BuildArch: ppc
Prefix: /QOpenSys/pkgs
%description
wc3270 is a suite of 3270 emulators for IBM i including c3270, x3270, and s3270.
%files
/QOpenSys/pkgs/bin/b3270
/QOpenSys/pkgs/bin/c3270
/QOpenSys/pkgs/bin/pr3287
/QOpenSys/pkgs/bin/prtodir
/QOpenSys/pkgs/bin/s3270
/QOpenSys/pkgs/bin/tcl3270
/QOpenSys/pkgs/bin/x3270if
/QOpenSys/pkgs/etc/x3270/ibm_hosts
/QOpenSys/pkgs/share/x3270/ibm_hosts
%install
# Make sure buildroot directories exist
mkdir -p %{buildroot}%{_bindir}
# mkdir -p %{buildroot}%{_sysconfdir}/x3270
mkdir -p %{buildroot}%{_datadir}/x3270
mkdir -p %{buildroot}/QOpenSys/pkgs/etc/x3270
# Copy binaries into standard bindir
cp /tmp/wc3270-package/QOpenSys/pkgs/bin/b3270 %{buildroot}%{_bindir}/
cp /tmp/wc3270-package/QOpenSys/pkgs/bin/c3270 %{buildroot}%{_bindir}/
cp /tmp/wc3270-package/QOpenSys/pkgs/bin/pr3287 %{buildroot}%{_bindir}/
cp /tmp/wc3270-package/QOpenSys/pkgs/bin/prtodir %{buildroot}%{_bindir}/
cp /tmp/wc3270-package/QOpenSys/pkgs/bin/s3270 %{buildroot}%{_bindir}/
cp /tmp/wc3270-package/QOpenSys/pkgs/bin/tcl3270 %{buildroot}%{_bindir}/
cp /tmp/wc3270-package/QOpenSys/pkgs/bin/x3270if %{buildroot}%{_bindir}/
cp /tmp/wc3270-package/QOpenSys/pkgs/etc/x3270/ibm_hosts \
%{buildroot}/QOpenSys/pkgs/etc/x3270/
# Copy config file to sysconfdir
# cp /tmp/wc3270-package/QOpenSys/pkgs/etc/x3270/ibm_hosts %{buildroot}%{_sysconfdir}/x3270/
# Optionally copy to datadir if needed
cp /tmp/wc3270-package/QOpenSys/pkgs/etc/x3270/ibm_hosts \
%{buildroot}%{_datadir}/x3270/
Run rpmbuild
rpmbuild -bb ~/rpmbuild/SPECS/wc3270.spec
~/rpmbuild/RPMS/ppc/wc3270-4.5-1.ibmi7.4.ppc.rpm — ⬇ download wc3270-4.5-1.ibmi7.4.ppc.rpm
Verify installed file list
rpm -qlp ~/rpmbuild/RPMS/ppc/wc3270-*.rpm
/QOpenSys/pkgs/, which is the standard location for IBM i open-source software managed through YUM/RPM.
A1Annex — Create a Patch File
To generate full_diff.good5.patch from your customized source tree, both the original and modified directories must sit at the same parent level. Clean the customized tree of all generated files first.
cd suite3270-4.5.good5/
diff -ruN \
--exclude='config.log' \
--exclude='config.status' \
--exclude='*.o' \
--exclude='Makefile' \
--exclude='obj' \
../suite3270-4.5 . > full_diff.good4.patch
A2Annex — Apply the Patch File
Place full_diff.good4.patch at the same directory level as suite3270-4.5/. The source tree must be vanilla (freshly unpacked). Always run a dry-run first:
cd suite3270-4.5
# Dry-run: verify the patch applies cleanly without modifying any files
patch -p1 -N --dry-run < ../full_diff.good4.patch
# Real apply: modifies the source tree permanently
patch -p1 -N < ../full_diff.good4.patch
-N flag ignores already-applied hunks. If the dry-run reports no errors, the real apply is safe to run.
A3Annex — Quick Smoke Test
After installing, do a quick sanity check to confirm the c3270 binary works and links correctly. Set the locale variables and connect to localhost:
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
c3270 localhost