A while ago, I wrote up a quick guide about running X/Windows applications (specifically, aterm) without root windows on Windows, using Cygwin. Recently I tried to set it up again and I realized that some of the information is slightly out of date. I'm also endeavoring to write a better guide. I'm assuming that you have, at the very least, a decent understanding of building things from source. The process under Cygwin is pretty much the same as under any other *nix, but there are a few quirks. On the whole, it's a whole lot easier than it used to be. This guide is primarily geared towards running aterm with a transparent background on a windows machine so that you can have a decent client for the Cygwin commandline, instead of the crappy Windows one.
I'm assuming that you already have Cygwin installed. If you don't, you can get it from here. In addition to whatever other packages you have selected to customize your install, you also need development packages (gcc and friends), Xorg packages (headers, includes, and libraries), and a few graphics libraries (for aterm):
- Devel
- gcc-core
- gcc-g++
- libXaw3d-devel (for xv)
- libjpeg-devel (for aterm)
- libpng12-devel (for aterm)
- Libs
- jpeg (for aterm)
- libXaw3d-devel
- libXaw3d-7
- libfreetype6
- libjpeg-devel
- libjpeg62 (for aterm)
- libjpeg6b (for aterm)
- libpng12 (for aterm)
- libpng12-devel (for aterm)
- libtiff5 (for aterm, xv)
- zlib-devel (for aterm)
- zlib0 (for aterm)
- Utils
- bzip2 (to handle .bz2 files)
- X11
- libX11-devel
- xinit
- xsetroot (if xv doesn't work for you)
After Cygwin finishes installing those packages, grab the sources for libAfterImage, aterm, and xv. Unpack the sources perform the requisite steps to build and install from source (./configure, make, and make install should work if all goes well).
libAfterImage:
If you get "parse error before XErrorEvent" errors while building libAfterImage, make sure that you didn't forget to select the X11 development package.
aterm:
gcc on Cygwin expects --rdynamic and not -rdynamic. If you're seeing these errors, edit the Makefiles under src and src/graphics within the aterm source directory. Change the "-rdynamic" to "--rdynamic". The changes should be on line 54 for both files.
xv:
Under the tiff directory within the xv sources, there is a file called RANLIB.csh. Edit this file and make sure that you ONLY have the following line in there:
ranlib $1 >& /dev/null
Otherwise the build process will fail. Additionally, you need to edit xv.h. This file lives right at the root of your xv source directory. If you do not perform the following change, you'll get errors from gcc complaining that "sys_errlist has previously been defined". Change line 119 of xv.h to:
/*extern char *sys_errlist[]; */ /* this too... */
What you're doing is commenting out the definition for sys_errlist so that it doesn't conflict with what has already been defined in the Cygwin header files. These changes should be the only ones you need to get xv compiling and running.
Now you need to set up two batch files. One to start up X rootlessly, and another to start up aterm. Before you do that, make sure you add C:\cygwin\usr\bin and C:\cygwin\X11R6\usr\bin to your PATH variable. You can do this by going to My Computer > Properties > Advanced > Environment Variables. If you don't do this, you'll get "cygwin1.dll not found" errors while trying to run these batch files. The X windows binaries used to live in C:\cygwin\usr\X11R6\bin, but have since been moved to C:\cygwin\usr\bin. Therefore, the start-up batch-file now looks like this:
xwin.bat:
C:\cygwin\usr\X11R6\bin\run.exe C:\cygwin\usr\bin\xwin.exe -multiwindow -clipboard -silent-dup-error C:\cygwin\usr\X11R6\bin\run.exe C:\cygwin\usr\local\bin\xv.exe -display :0 -root -quit -be -max /cygdrive/c/Documents\ and\ Settings/vivin/My\ Documents/My\ Pictures/Wallpapers/01707_spectrumofthesky_1920x1200.jpg
The first line starts up the X windowing system. The second line sets the wallpaper using aterm. You now need another batch file to run aterm, and that looks like this:
aterm.bat
C:\cygwin\usr\X11R6\bin\run.exe C:\cygwin\bin\bash.exe --login -i -c "aterm -sh 80 -tr -trsb -fade 20 -tint gray -sb -st -sr -sl 1000 -tn xterm"
This file starts aterm with the background image at 50% brightness, transparent background, transparent scrollbar, 20% fading on losing focus, gray tint, scrollbar, trough-less scrollbar, scrollbar on the right, 1000 scrollback lines, and with xterm terminal emulation. Like I mentioned in my original guide. xv will sometimes fail to start with xwin. If that is the case, you can modify aterm.bat to look like this:
aterm.bat:
C:\cygwin\usr\X11R6\bin\run.exe C:\cygwin\bin\bash.exe --login -i -c "xv -display :0 -root -quit -be -max /cygdrive/c/Documents\ and\ Settings/vivin/My\ Documents/My\ Pictures/Wallpapers/01707_spectrumofthesky_1920x1200.jpg && aterm -sh 80 -tr -trsb -fade 20 -tint gray -sb -st -sr -sl 1000 -tn xterm"
Slightly inefficient, but it works. Now if you have a dual-monitor display, you'll notice that the background image is stretched across both screens when you run aterm. This is probably not what you want. To fix this problem you need to change a few invocation options for xv. For this to work properly (meaning, not look crappy) both screens should be running at the same resolution:
xv -display :0 -root -quit -be -maxpect -rmode 1 /cygdrive/c/Documents\ and\ Settings/vivin/My\ Documents/My\ Pictures/Wallpapers/01707_spectrumofthesky_1920x1200.jpg
Notice the -maxpect and -rmode 1 options. -maxpect expands the image to fill the screen while maintaining the aspect ratio, while -rmode 1 sets the display mode on xv to tiled. So you should now have your wallpaper displaying on both screens now (under X) without being distorted.
Here's what it looks like on my machine:
This is on a dual-monitor setup with both screens running at 1920x1200 resolution. I've set X's background to be the same as my windows Wallpaper so that it looks cooler. Notice how the background image (inside aterm) is not stretched, but tiled across the two screens. That's all there is to it. Seems like a bit of work, but I think it's worth it. My main reason for going through all this trouble was to get a decent terminal running in windows. I guess I could have just used xterm, but aterm looks so much nicer, doesn't it?
Hello. This could well be a stupid question, but I get the following when running ./configure for libAfterImage.
$ ./configure
checking for gcc… gcc
checking for C compiler default output file name… a.exe
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables… .exe
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ANSI C… none needed
checking whether ln -s works… yes
configure: error: cannot run /bin/sh ./config.sub
Any ideas?
Thanks,
Phil
Hello Phil,
Not a stupid question at all 🙂 I was able to find three possible solutions:
On Linux, ./config.sub is usually a symlink to something. Try doing an ls -l on that directory to see what it’s trying to point to. From some research, the most common problem seems to be a missing libtool, so you may need to install that through Cygwin’s setup. But since this is a Linux-specific issue, it may not apply to Cygwin.
You can also try setting CONFIG_SHELL to /bin/sh.exe and then running make again. (export CONFIG_SHELL=/bin/sh.exe)
Another problem might be related to the way you’re unpacking the archive file. If it was a zip, don’t use Windows to unzip the file since it clobbers the line-endings. Use Cygwin’s unzip utility instead.
Hope this helps!
Thanks, that did help. The problem was the unpacking of the archive file. I used the .tar.bz2 file which winzip screwed up. Uncompressing and untaring the file made it work.
Then I had to install few more cygwin libraries to get the configure to complete, so that bit now works (with the exception of this bit, which I’m assuming I can ignore:
…
checking pkg-config is at least version 0.9.0… yes
checking for SVG… checking headers required by TTF support… ./configure: line 8194: freetype-config: command not found
none found
You have to install FreeType libary in order to be able to use TTF fonts.
checking libAfterBase… disabled
checking for dirent.h that defines DIR… yes
…
Then it makes the Makefile but I can’t get this to run successfully. It comes up with this:
$ make
make: makefile: line 130: Warning — Duplicate entry [libAfterImage.a] in prerequisite list
gcc -O3 -DNO_DEBUG_OUTPUT -Wall -mmmx -Winline –param inline-unit-growth=10000 –param large-function-growth=10000 -c libungif/dgif_lib.c -o libungif/dgif_lib.o
make: Error — gcc: The system cannot find the file specified.
make: Error code -1
Looking in the libungif directory dgif_lib.c exists.
gcc is on the path and the ./configure script finds it ok.
Do you have any idea what might be causing this?
I will continue to look but am doing this alongside work related stuff.
Cheers,
Phil
Hmmm… that’s a strange one. I don’t recall whether Freetype is required or not. Maybe you can try installing it? I believe it’s there in Cygwin setup. What other libraries did you have to install?
The problem with these kinds of errors is that it’s not immediately obvious what is wrong. I’d try installing the Freetype library (I think it’s libttf or libfreetype) and see if that helps. Hopefully it’ll get a little further in the build process.
Thank you for this writeup!!!
Nice article; thanks for the info. A sort of related but now aging project is the XliveCD: http://xlivecd.indiana.edu/.
My question: do you have a link to your wallpaper anywhere?
Hi,
Thanks for that link! That’s pretty useful actually, especially when I’m on a system that doesn’t have Cygwin installed!
I got my wallpaper from interfacelift.com, but you can just download it off my server.
Hi Vivin,
Thanks for preparing this help. However, I had some problems compiling the libAfterImage library. I keep getting the following error. Any ideas?
Thanks a lot.
Cihan
gcc -O3 -DNO_DEBUG_OUTPUT -Wall -I.. -c ascompose.c
In file included from /usr/include/X11/extensions/shape.h:62,
from ascompose.c:47:
/usr/local/include/X11/Xutil.h:93: error: parse error before "Bool"
/usr/local/include/X11/Xutil.h:96: error: parse error before "icon_pixmap"
/usr/local/include/X11/Xutil.h:97: error: parse error before "icon_window"
/usr/local/include/X11/Xutil.h:99: error: parse error before "icon_mask"
/usr/local/include/X11/Xutil.h:100: error: parse error before "window_group"
/usr/local/include/X11/Xutil.h:136: error: parse error before "Atom"
/usr/local/include/X11/Xutil.h:139: error: parse error before ‘}’ token
/usr/local/include/X11/Xutil.h:182: error: parse error before "XPointer"
/usr/local/include/X11/Xutil.h:184: error: parse error before ‘}’ token
/usr/local/include/X11/Xutil.h:226: error: parse error before "Visual"
/usr/local/include/X11/Xutil.h:240: error: parse error before ‘}’ token
/usr/local/include/X11/Xutil.h:259: error: parse error before "Colormap"
/usr/local/include/X11/Xutil.h:267: error: parse error before "visualid"
/usr/local/include/X11/Xutil.h:268: error: parse error before "killid"
/usr/local/include/X11/Xutil.h:322: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:328: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:337: error: parse error before "XRectangle"
/usr/local/include/X11/Xutil.h:355: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:382: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:389: error: parse error before "XGetClassHint"
/usr/local/include/X11/Xutil.h:391: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:397: error: parse error before "XGetIconSizes"
/usr/local/include/X11/Xutil.h:399: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:406: error: parse error before "XGetNormalHints"
/usr/local/include/X11/Xutil.h:408: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:414: error: parse error before "XGetRGBColormaps"
/usr/local/include/X11/Xutil.h:416: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:424: error: parse error before "XGetSizeHints"
/usr/local/include/X11/Xutil.h:426: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:433: error: parse error before "XGetStandardColormap"
/usr/local/include/X11/Xutil.h:435: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:442: error: parse error before "XGetTextProperty"
/usr/local/include/X11/Xutil.h:444: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:452: error: parse error before "XGetWMClientMachine"
/usr/local/include/X11/Xutil.h:454: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:460: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:462: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:467: error: parse error before "XGetWMIconName"
/usr/local/include/X11/Xutil.h:469: error: parse error before ‘*’ token
/usr/local/include/X11/Xutil.h:475: error: parse error before "XGetWMName"
Hey Cihan,
Did you install libX11-devel?
Hi Vivin,
Thanks for this helpful article. I get the following error when compiling libAfterImage. Any ideas?
Thanks.
Cihan
gcc -O3 -DNO_DEBUG_OUTPUT -Wall -I.. -c ascompose.c
In file included from /usr/include/X11/extensions/shape.h:62,
from ascompose.c:47:
/usr/local/include/X11/Xutil.h:93: error: parse error before "Bool"
/usr/local/include/X11/Xutil.h:96: error: parse error before "icon_pixmap"
Hey Cihan,
I think it might be related to libX11-devel. Did you install that package from Cygwin setup?
Hi Vivin,
Wow, thanks for the quick response. 🙂
Yes, I did install libX11-devel. Is it possible that I am missing another library that you did not list above?
Thanks a lot.
Cihan
No problem 🙂
I think I may have forgotten to list xorg-x11-devel. Let me know if installing that package works. I’m pretty sure it has to do with an X development library since it looks like gcc isn’t able to figure out what those symbols mean.
According to the cygwin package list http://www.cygwin.com/packages/ xorg-x11-devel seems to be obsolete. It is not listed in the cygwin setup list anymore also.
Hmmm…
What other development packages are there under x11? I’m on a Linux box right now so I can’t check. Those symbols seem to be part of Xlib. Did you install xinit?
I have a few questions about this:
1) Once I compiled all of these, where are the binaries? I put the tar.gz/tar.bz2’s in the /home/smith directory, and compiled everything there.
2) I don’t know if I have all the X things installed… a different tutorial somewhere said there were more packages to install with X, but they weren’t there.
3) What do I do with the .bat files once I’ve made them?
Thanks!
-BMatt
@BMatt
1) When you do a make install it should put the binaries in /usr/bin.
2) If you were able to build everything successfully then all your X development stuff probably has been installed.
3) Try running them – just double click on them. You can also make a link to them on your desktop so you can launch your terminal just with a click. You probably want to put the xwin.bat as part of your startup so that X starts when you log into Windows. Then all you need to do is launch the aterm.bat file to open your terminal.
Thanks, I have a couple more questions. I can navigate to /usr/bin within Cygwin, but not in Explorer. I want to get there in Explorer so I can look through the files easier (is it just in C:\cygwin\bin\ ?). When I try using the command aterm, it gives me a command not found error. Is this not the command to run it? Thanks again!
@BMatt
I believe it’s C:\cygwin\bin or C:\cygwin\usr\bin
Where are you running aterm from? Are you trying it from the batch file? Also, did you have any errors in the build process, or did everything install properly? You need to make sure that after configure, you run make and then make install.