PDA

View Full Version : Porting QT linux programs to windows. Use cygwin?



philp
16th August 2012, 17:21
Hi
I am trying to port some QT sources from Unix to Windows. One of the apps is using rpc and sockets etc (the Unix way). Whats the best method I should use to port this across. Obviously I would like to minimize the changes I have to make to the code.

Is one option to install cygwin and use that to build the application some how?
Do I first need to build QT using cygwin?

Or should I be looking at using a cross-compiler on linux to build the windows app?

I'm just unsure of the best way to proceed.

Can anyone give me any advice?
Thanks

maximebd
16th August 2012, 18:32
Like you said, using rpc and sockets is the Unix way. I personally don't know rpc (http://linux.die.net/man/3/rpc) very much, but I don't think there are any obvious ways of porting it to windows right away. Cygwin might be one option, but then you need to compile Qt for cygwin and deploy with the cygwin dll and even then I wouldn't be surprised to run into problems. If both processes are going to be on the same machine then QSharedMemory could help. Otherwise I would abstract your IPC code and code different implementations for the different platforms. On Windows, I have had some fair success using the NamedPipe (http://msdn.microsoft.com/en-us/library/windows/desktop/aa365150(v=vs.85).aspx) family of functions. There are also other libraries (http://stackoverflow.com/questions/4352131/c-rpc-library-suggestions?lq=1) that could help, including Boost.Interprocess (http://www.boost.org/doc/libs/1_50_0/doc/html/interprocess.html).

philp
17th August 2012, 10:58
Thankyou for your help maximebd.

I've been googling this problem for a while now. I have found sites where people have successfully, but with significant problems build QT using cygwin. I think those problems would have defeated me much sooner.
I've not been able to find any proof that applications in general can relatively simply be ported across using cygwin and so I am going to chicken out for now.

From what you are saying and from what I have read, it looks like cygwin is not really the answer that I am looking for (that is unless someone can tell me otherwise). Even if I can build QT with cygwin you indeed suggest that my applications may well not work anyway...so it looks like I need to port the platform dependent code over.
To be quite honest, what I am doing is experimental, basically I am investigating how difficult it would be to port some of my QT apps across to windows. Most of them have gone across nicely, but one has a lot of platform dependent stuff in it. Some of this stuff could be re-written using QT and some of it I will have to look into windows native ways to do the job.

So I am going to simply build my QT app with the platform dependent stuff compiled out (for now) and maybe port hem across later.

Thanks again for your thoughts

d_stranz
17th August 2012, 17:35
Qt has implementations for sockets (QAbstractSocket and subclasses) and for rpc (D-Bus). Why not rewrite the linux-dependent code to use the Qt classes and get that working, then look for a D-Bus implementation for Windows (like this one (http://www.freedesktop.org/wiki/Software/dbus))? Then you've ported once and for all and can have something really platform independent.

Personally, I use Visual Studio for all of my Windows coding; it's one less thing to worry about

philp
21st August 2012, 10:27
Thanks d_stranz

I will indeed try and do that. I have successfully compiled out all the dependent stuff. Will check it runs ok, and then will port stuff over...and where possible I will use qt independent code. When I get time I will look into trying visual studio to see how that cane help me.

Thanks very much for your time