sunnuntai 8. elokuuta 2010

Cross-compiling Qt applications for Windows, the easy way

For a while I've been looking for a way to cross-compile my Qt app for Windows on Linux. I don't have any Windows PC's at home or at office, so native build is out of question. There are several instructions how to do this, but they involve cross-compiling the whole Qt from source and a lot of other manual work.

I found and easier way using Wine.

1. Install Nokia Qt SDK for Windows using Wine. It should install fine.

2. Create a build script that does something like this:

export QTDIR=$HOME/.wine/drive_c/Qt/2010.04
export Path=C:\\windows\\system32\\\;C:\\windows\\\;C:\\windows\\system32\\wbem\;C:\\Qt\\2010.04\\mingw\\bin\\\;C:\\Qt\\2010.04\\qt\\bin\\\;\
C:\\Program\ Files\\NSIS\\
cd app_directory
wineconsole --backend=curses qmake.exe
wineconsole --backend=curses mingw32-make.exe

3. That's it! You should now have a working .exe in yout project directory. You can run it using wine.

When shipping your application, you need to include the required mingw and Qt DLL's with it. For example:

$QTDIR/qt/bin/mingwm10.dll
$QTDIR/qt/bin/libgcc_s_dw2-1.dll
$QTDIR/qt/bin/QtCore4.dll
$QTDIR/qt/bin/QtGui4.dll
.. and any other DLL's your app needs. Remember to use the d-versions if you build your app in debug mode.

For SQL drivers install them into directory named sqldrivers in the directory where your .exe is installed. For SQLITE the DLL is $QTDIR/qt/plugins/sqldrivers/qsqlited4.dll.

If you want to create an installer, I can recommend the open source Nullsoft installer (NSIS).

maanantai 31. toukokuuta 2010

RC Hornet first flight

Recently I bought a F-18 Hornet model from Bananahobby.com. It's a ARF foamie which is pre-painted and looks pretty good. It has a brushless electric ducted fan motor and a 4 cell LiPo battery pack. The model took a few hours to build, most time taken by gluing wings and stabilizers and installing servo wires. The kit had a 2.4Ghz radio included and installed, but i opted to use my own DX7 with it's 7 channel receiver. If you or your friends need a cheap 4 channel RC radio set at Tampere area, let me know. I haven't tested if the receiver works with DX7 yet.

I also decided to connect left and right ailerons to different channels in receiver and thus making them flaperons with DX7's mixing functions.

Yesterday was the first flight day. First i flew with a full size sailplane (LS-8) and then made some preparations and waited for a rain shower to go away. When the rain stopped, weather was semi ok for first flight - there was some light wind but no strong gusts.



Pre-flight photo.

The flights went fine. I flew 3 flights, totalling maybe 15 minutes. I was alone at the airfield so there are no in-flight photos, sorry. The model has plenty of power - maybe close to 1:1 power to weight ratio. Cruising can be done at half throttle. It's also surprisingly stable - center of gravity is so low that it tends to correct any bank by itself. It's also pretty agile and looks great in flight. It's not easy to fly though - for example stalling can cost 10 meters of altitude easily. Landings must be done pretty carefully and at low angle to avoid hitting ground tail first.

I tried using flaps (both up and down) but they caused huge trim change and almost losing control so i didn't use them during landings yet.

The ESC that came with the kit doesn't warn about low battery by cutting power like ESC's usually do. This one just outputs less power which came as a surprise to me and caused unscheduled landing. I guess I'll have to have a stopwatch to estimate flight time left.



Construction pic. Electronics are behind the plastic door which is glued into the fuselage.



Looks like I'll have to buy a larger car if I want to get larger models than this.


Link to the model (it's on sale now!):

http://www.bananahobby.com/1940.html

perjantai 26. helmikuuta 2010

Converting music to mp3 in place

I bought a new car stereo a while ago. I'm not going to specifics about it as this is not a car hifi blog. What's interesting is that the player can play mp3's from CD, USB memory and SD card.

My digital audio collection is mostly in ogg and flac format for better quality/file size and the player can't handle them. I tried to find a nice solution to mass convert files from ogg/flac to mp3 but none of them were satisfactory so i wrote my own script:


#!/bin/bash
# Convert flac & ogg audio to low quality mp3 for mobile playing.
# By Ville Ranki

find -type f -name "*.flac" -o -name "*.ogg" | while read file
do
outfile=`echo $file | sed 's/\.[^\.]*$/.mp3/'`
echo "Converting $file to $outfile"
gst-launch-1.0 filesrc location="$file" ! decodebin ! audioconvert ! lamemp3enc target=quality quality=4 ! id3v2mux ! filesink location="$outfile"

if [ -f "$outfile" ];
then
   echo "Removing original $file"
   rm "$file"
else
   echo "Error: File $outfile was not created."
fi

done



This script will find recursively all files in current directory, convert them to mp3's (while preserving id3 tags) and delete the original files. It preserves directories as they are - my car player should be able to browse by directory although i haven't figured out how to do so.

I use it by copying wanted music to a temporary directory, run the script in the directory and copy the results to usb stick or other media.

Make sure you have all the commands installed before running the script, such as gst-launch-0.10. Also don't run the script where the original collection is or you'll lose it. Copy files somewhere else first.

I hope this is helpful for others with the same problem.

(Updated 23.7.2015 for gst-launch-1.0 and simplified the script at the same time)

sunnuntai 13. joulukuuta 2009

Sergei gunsight without the cover

I'd like to add a couple more photos about the gunsight and how it looks without the cover. The cover reduces some glare and is good for anti-aircraft guns but for aircraft it may block visibility too much so most ww2 aircraft have the gunsight without any cover.

Well, here are the photos:


Side view. The reflector glass is in 45 degree angle.

Another view

Looking through the gunsight.

Looking through, from longer distance


This is what it looks like from top of the gunsight. It shows the reticle through the glass and inverted reflection.

For the simpit i'll naturally remove the cover. This way the gunsight looks just like any WW2 fighter's gunsight. At least il2 supports removing any on-screen sights so maybe i'll even get to play some games with hardware gunsight. Otherwise it'll just look cool :-)

Btw notice how the size of reticle is always the same regardless of the distance. That's how the reflection gunsight (and modern HUDs) are supposed to work.

Next step is to mount the thing to the simpit. Let's see when that happens, as i have some other projects (hacks) to do such as the RC 109 used as practice target in photos above.

perjantai 11. joulukuuta 2009

Sergei gunsight illuminated

Long time no post.

Today i built a light for the sergei gunsight i've had for some time. It illuminates the reticle so it's more visible in various lighting conditions. Here's the photos:

Lamp assembly is mounted on the bottom of the gunsight. The assembly is actually a plastic cap from a Pisang Ambon liquer bottle.


This is the lamp holder, looking inside. Inside i put a piece of paper to spread the light evenly. Without the paper reticle was uneven as the light bulb could be seen through the reticle.


This shows the whole reticle. Pretty nice!


Comparison: Light turned off


Light turned on!

Photos taken with my new Nokia N900 phone. Less bad than the previous ones.

lauantai 25. huhtikuuta 2009

F-18 simulator on TV

They showed Finnish Air Force's WTSAT F-18 simulator on tv in "Äijät" tv show. It's in Finnish, but i think everyone understands what's the idea. See the whole episode at:

http://www.sub.fi/netti-tv/index.shtml/ohjelmat/aijat?12856

Also getting to fly a Hawk is quite cool.

torstai 23. huhtikuuta 2009

Velocity EP second flight

Today i got Velocity EP finally repaired and ready to fly. I installed the new electronics -

* CC Phoenix 45 ESC
* Ultrafly A/30/24 brushless motor
* AR6200 2.4GgHz receiver

- to the plane. My new shiny transmitter is Spektrum DX 7, which i got for discount as the shop didn't get DX6 in time. DX 7 is maybe a bit too high end for my use, but now i got it and it's really cool. Motor was compatible with Speed 400 and the mount didn't need modifications.

The flights went good. This time i didn't crash the plane and flew very carefully (no high speed passes or low level aerobatics). Performance is AWESOME. 5 seconds with full throttle and the plane is so high i don't want to get it higher. Normal aerobatics such as loops and rolls are possible with 50% throttle. Level flight requires about 30% throttle. Thrust/Weight ratio is about 1. And this is not a lightweight depron model. I flew about 30 minutes and didn't get the battery to run out. I had to quit, because it became dark and cold.

Velocity glides surprisingly well. I needed a few passes every time i tried to land it. Almost like Zagi 400. I don't think it can thermal though as it loses altitude rapidly when turning.

Sorry, no photos this time as i was flying alone.

Next time i'll try how fast it goes. My fear is that it might disintegrate mid-air. Let's see what happens.