sunnuntai 8. helmikuuta 2009

Porting QFLR5 for Ubuntu



I have found the XFLR5 X-foil front-end pretty nice as the original X-foil is a bit hard to use. I have been able to run the XFLR5 on Ubuntu with wine, however, it is not without bugs when run under wine. So there is an another alternative - use a native Linux version that does not officially exist yet.

The author of the program has been working on a Qt-version (it is there in the svn). I tried to compile it to Ubuntu. However, because it was using the windows.h min and max, it didn't compile out of the box today.

I created the following patch (the blogger makes the patch look incorrect, please look at the actual patch file, from here if you want to use it: karoliina-minmaxlinuxpatch.diff ):

karoliina@aurora:~/MyProjects/xflr5/branches/QFLR5$ more karoliina-minmaxlinuxpatch.diff
Index: Objects/Foil.cpp
===================================================================
--- Objects/Foil.cpp (revision 62)
+++ Objects/Foil.cpp (working copy)
@@ -32,6 +32,7 @@
#include
#include
#include
+#include

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
@@ -625,7 +626,7 @@
{
//Returns the foil's length

- return max(m_rpExtrados[m_iExt].x, m_rpExtrados[m_iInt].x);
+ return std::max(m_rpExtrados[m_iExt].x, m_rpExtrados[m_iInt].x);
}

double CFoil::GetLowerY(double x)
@@ -881,8 +882,8 @@

for (i=0; i> m_NXPanels[i];
- m_NXPanels[i] = max(1,m_NXPanels[i] );
- m_NXPanels[i] = min(MAXCHORDPANELS, m_NXPanels[i]);
+ m_NXPanels[i] = std::max(1,m_NXPanels[i] );
+ m_NXPanels[i] = std::min(MAXCHORDPANELS, m_NXPanels[i]);
}

for (i=0; i<=m_NPanel; i++) @@ -1442,8 +1442,8 @@ m_NYPanels[i] = (int)f; } else ar >> m_NYPanels[i];
- m_NYPanels[i] = max(1,m_NYPanels[i] );
- m_NYPanels[i] = min(50, m_NYPanels[i]);
+ m_NYPanels[i] = std::max(1,m_NYPanels[i] );
+ m_NYPanels[i] = std::min(50, m_NYPanels[i]);
}
int total = 0;
for (i=0; i


This patch replaces the min and max to std::min and std::max, ensuring the min and max from are being used. This enables the successful compilation on Ubuntu side.

I have a temporary binary (no debian package yet, I need to agree with the developer when it would be ready for packaging), available for Ubuntu Intrepid:

http://www.katix.org/karoliina/packages/QFLR5-ubuntu-intrepid-bin