By coincidence, today I arrive to the ACCU website. ACCU is an organisation of programmers who care about professionalism in programming and are dedicated to raising the standard of programming. They publish a magazine (C Vu) and a newsletter (Overload), and organize a yearly conference in Oxford, UK. Slides from last year’s conference are available online and seem quite interesting. Next year‘s conference is from April 22 to April 25 and one of the three tracks will be about patterns.
This is mostly a self-reminder
I attended aKademy 2008 and there are so many things to write about I don’t even know what to start with. I’ll probably write something in a few days, when I’m feeling less sick (thanks to a Flemish waiter who had the OpenBossa guys, Knut and I waiting for almost one hour for dinner, I got a cold).
As you may know, part of my job (and hobby, too) consists on “shaking” software to make it compile on different platforms and with different compilers: I port Linux software which builds with gcc to Windows with Visual C++, or Visual C++ to MingW, or… well, whatever. It’s funny.
Back on topic: Wednesday as the Sun tutorials day and I got immediately interested in Sun Studio. Message to Sun Microsystems people: your installer is so broken on Linux it is impossible to make it work on Debian and Ubuntu (and I guess on anything other than RHEL). The only way I found to “install” SS12 was to download the Express version, remove the sh-code and untar the resulting package. It works but it’s so nasty hardly anybody would try that.
Sun Studio 12 is 100% ISO C++ compliant, which means support for wchar_t is not as good as most applications require nowadays. The best way to overcome this limitation is to use Apache Foundation’s STDCXX to replace SS12’s STL (which is STLport 4 (according to Adriaan, stdcxx would roughly correspond to STLport 6)
Building STDCXX is relatively easy, if you know the tricks:
- export PATH=/path/to/sunstudioceres/bin/:$PATH
- export CC=/path/to/sunstudioceres/bin/suncc
- export CPP=/path/to/sunstudioceres/bin/suncc
- export CXX=/path/to/sunstudioceres/bin/sunCC
- You should be able to do this step by exporting CFLAGS, etc but it won’t work, so edit stdcxx-4.2.1/etc/config/sunpro.config and:
CXXFLAGS = -library=no%Cstd -YI,/path/to/source/of/stdcxx/include/
CPPFLAGS = -YI,/path/to/source/of/stdcxx/include/
LDFLAGS = -library=no%Cstd
At the moment, I’m trying to get Wt built with Sun Studio 12 on Linux. Given that SS12 is the compiler of choice for KDE4 on Solaris, I may try to get KDE4 built on Linux with SS12 at a later stage. That would help both the Solaris port and the Linux code.
PS: Hello Planet KDE
ffmpeg has been able to record a screencast on X11 for a long time now, using the x11grab input format and the :0.0 device (for the first instance of X). You’d run
ffmpeg -f x11grab -y -r 12 -s 800x600 -i :0.0+480,200 -vcodec ffv1 -sameq ./out.avi
and get a lossless video of the upper right 800×600 area of a 1280×800 desktop. Easy. You could even transcode to a lossy format (such as H.264, Xvid or Theora) if you had a powerful machine.
On Windows it was not that easy. First of all, Windows is not X11, so x11grab does not work on Windows. You need to use GDI or DirectX but ffmpeg did not have support for GDI or DirectX capture. If you wanted screen-grabbing features in you application, either you developed your own solution (ugly, specially because of the video encoding part) or you used Camtasia Studio (Wink does not include a DLL or ActiveX component you can use in your app).
Ramiro Polla and Christophe Gisquet had a heated discussion about one and a half years ago and some very interesting code was shown. Unfortunately, neither Ramiro’s nor Christophe’s code would work with current ffmpeg.
Today I’ve finally brought Ramiro’s code up to date and it works with ffmpeg trunk. It is not perfect, though: it does not capture the mouse pointer, contextual menus shown as a result of a right-click and video scaling and color is not perfect (ffplay shows the video a little blue-ish). Patch. I’ll try and bring Christophe’s code up to date tomorrow, or fix Ramiro’s code.
PS: A request for ffmpeg developers: please, replace your custom configure script with some cross-platform build system. I like CMake but Scons, Waf and others would also do.
Yesterday I stayed up until 4:30 AM while trying to fix Amarok to works on Windows and when I got it to build it was so late I was too tired to test it. So I fired it this morning and this is the result (click for larger images):
I have tested and it plays MP3, WMA, APE and whatever Magnatune streams on. Built with Visual C++ 2008.
Update Two more screenshots added and in case you were wondering, yes, Plasma works!
Yesterday I fixed the Phonon DirectShow 9 backend for Windows. Now audio and video are available to KDE applications on Windows, which means Amarok 2-trunk works! Currently, it can only play .WMA files (I think I have to install the .ax files for the MP3, MIDI, WAV, etc codecs in the KDE bin or libs directory, I’ll try and fix that next week). In the meanwhile, you need patch #6 if you want to build Amarok on Windows and hear something. Please note I’ve only tried to build it with MSVC2005, not MinGW, not MSVC2008 yet.
“Why, oh why?” I wondered. I had previously built Qt 4.4.0 using VC++2008.
Turns out on this computer I had installed the Visual C++ 2008 Feature Pack, which adds some nice stuff (if the Office 2007 look tastes nice to you) but also breaks some stuff (mostly MFC but also some math functions).
Fortunately, it’s easy to fix the issue: just do not #include <xmath> and everything will work fine. As the same codebase has to work with many other compilers, I cannot just get rid of that line of code: I need to #if-case it for VC++2008 with Feature Pack.
Unfortunately, there is no easy way to check for “VC++2008 with Feature Pack”. Sure, you can check for VC++2008 by checking _MSC_VER >= 1500. Easy. Unluckily, the only way to check for the Feature Pack is to check _MFC_VER (check you have MFC 9.0.30411 instead of 9.0.21022), which is only defined if you #include <afxver_ .h>. Of course that file #includes many other files, which means some ugly, confusing problem is waiting to happen.
How dumb can you be, Microsoft? Why aren’t you changing _MSC_VER, too, and make my life easier?
That’s the title of a very useful article by Scott Collins which describes how to combine Boost and Qt in the same application. Unfortunately, Scott’s website went dark many months ago and I’d say it’s not coming back. Luckily, I was able to get a copy from Google’s cache before it was squashed forever. I’d say right now this is the only place in the web you can get this wonderful article: A deeper look at signals and slots
Apache Log4CXX is a logging framework for C++ patterned after Apache log4j. It also happens to be quite difficult to build on Windows if you are using Microsoft Windows SDK 1.0 (AKA Microsoft Platform SDK 6.0). If you are building software for Windows Vista or Windows Server 2008, or using Visual C++ 2008, you are using Windows SDK 1.0.
The reason Log4CXX 0.10.0 is hard to compile with Windows SDK 1.0 is a bug in APR 1.2.12 (the latest version available as of this writing) and a bug in Windows SDK 1.0 itself (a preprocessor redefinition due to including twice a header file). Here comes the recipe in case you want to build the stuff yourself:
- Download APR 1.2.12 and extract it. Rename to apr.
- Download APR Util 1.2.12 and extract it. Rename to apr-util.
- Download Log4CXX 0.10.0 and extract it
- Download GNU Sed and install it
- Open cmd.exe and run %PROGRAMFILES%Microsoft Visual Studio 9.0VCvcvarsall.bat
- Apply the apr-1.2.12-win32.patch patch to fix bug 40398 in APR 1.2.12 (this step is not needed if you are using APR 1.2.13)
- Apply the log4cxx-0.10.0-vc90-support.patch patch
- Enter directory apache-log4cxx-0.10.0
- Execute configure.bat
- Execute configure-aprutil.bat
- Open the log4cxx.dsw solution When asked to convert the solution to VC++9, click Yes to All.
- Right click on Solution log4cxx and select Build solution
To my surprise, it seems that Visual C++ 9.0 finally un-breaks the min and max functions. Sadly, that breaks lots of code which used to do
Now those #ifdef‘s need to be changed to something like:
#if defined(_MSC_VER) && (_MSC_VER < 1500)
Those libraries have underwent so many changes that updating the whole software to Visual C++ 2008 and the newest versions of the 3rd party libraries would be a too difficult task to be accomplished in a reasonable amount of time, therefore I’ve decided I’m going to stick to old libraries as much as possible, while moving to Visual C++ 9.0. The next step would be to move to newer versions of the 3rd party libraries or even to remove most of those dependencies and make the software depend only on Qt.
For starters, stock Boost 1.33.1 did not build with VC++ 9.0 but after some digging and tweaking, it works. Here is how:
- Download Boost 1.33.1 and uncompress it. It does not support VC++ 9.0.
- Apply patch to support VC++ 9.0
- Open cmd.exe and run %PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
- boost_1_33_1\tools\build\jam_src and run build.bat
- Go to directory boost_1_33_1 and run tools\build\jam_src\bin.nt\x86\bjam.exe -sTOOLS=vc-9_0
- Run tools\build\jam_src\bin.nt\x86\bjam.exe -sTOOLS=vc-9_0 install to install to c:\boost