Migrate Win32 C/C++ Applications to Linux
An anonymous reader writes "This series of articles helps you migrate your Win32 C/C++ applications to Linux on POWER. Win32 C/C++ Apps to Linux Part-1 of this series covers the Win32 APIs mapping to Linux on POWER regarding the initialization and termination, process, thread, and shared memory services. Win32 C/C++ Apps to Linux Part-2 illustrates how to map Win32 to Linux with respect to mutex application program interfaces (APIs)."
I was thinking about this today. everyone complains that there isnt *Insert Random Program HERE* available for Linux, isnt part of the problem that most code being written isnt portable? eg its too dependant on specific libraries.
.
I cant write code myself, so obviously there is a lot that i dont know. But is it really that hard to write code that is portable?
Thoughts , Ideas?
Comments and/or Flames should be posted below this line
---------------------
Yeah, but aren't most computers running Linux backend servers? In terms of desktop users that need program X, I'd imagine there are more Mac users than Linux users.
IMHO, the ease or difficulty in porting an application really begins at the design stage. If you design for a standard(GUI apps excepted) like POSIX then porting is much easier. Granted that many things on Windows become more difficult but usually not impossible. I have written many apps over the years for diverse platforms and usualy only have to rewrite one module that contains the platform specific code. For example, calling SYS$ & LIB$ functions on OpenVMS. However, whe it comes to the GUI then things get a lot more indeterminate which it where the auhor is coming from. There are some tradeoffs to be done here. Either:- 1) Design for performance 2) Design for portability If you take the former and for example, design the GUI using Visual Studio tools then you will get something that will work and perform well on Windows but moving to other platforms is nigh on impossible. So, where do we go in the future? Well Microsoft would want you to go down the .NET route but they ave singularly failed to release it for other platforms. Mono is there but it does not have the cachet of Mictosoft support which is needed in many companies.
Java is pretty portable and there are lots of skill out there to continue development.
There are other niche languages & environments that are portable but these have their roots in OSS and sometimes trying to itroduce something like Python into a totally Microsoft shop is like trying to make the Red Sea part. {I know as I tried this and was regarded as a subversive influence.}
The overall situation is cloudy but there are breaks of sunlight where Portability is a prime consideration and the company can reap the benefits in a MultiPlatform world.
I'd rather be riding my '63 Triumph T120.
I am not that familiar with WINE, but isn't there a package to install on Windows that integrates nicely with VisualStudio where you can simply check to see if your application will also work on Linux under WINE? That way, it would make developers conscious of whether they were using libraries that would make it incompatible with WINE. Is this already possible?
Use wrappers.
Or better yet, dont use a SYSTEMS language for APPLICATIONS, use C# on Mono and GTK bindings or something or Java etc.
C and C++ and so on are SYSTEMS languages and applications in usermode should sit on a VM really, welcome to the year 2005. Performance, please, thats an stupid argument, you can compile and not run in JIT mode easily with virtual machine languages, you just lose out on dynamic optimisations that any JIT compiler may have and son on.
And source code delivery has nothing to do with it being commercial or free, in either the "beer" or "speech" sense. When the software is important enough, having the source code is an absolute necessity which every system administrator will insist upon. There's a disturbing meme going through the industry that "COTS" (commercial, off-the-shelf) software can be sold without source code. That's bullshit. When your company's business is totally dependent on a system, you must have access to the source code, no matter what the licence is.
Unfortunately it doesn't cover the really fun part -- mapping windows Event into pthread's Conditional Variable.
I passed the Turing test.
Personally I've just moved TCHAR.H around. I worked on a cross platform product a few years ago. I wrote it for Win32, and somebody else handled a Mac OS version. I kept the UI, etc separated out. It wasn't until late in the project that we decided that the Win32 build would be Unicode instead of multi-byte. I had used the TCHAR.H defines throughout all of the common code which of course made this decision easy as Microsoft have done a good job with the I18N stuff. TCHAR.H copied over to the Mac just fine and there were no problems with the common code on that platform.
I'm not sure if this should be a reply to someone else's comment, so I'll start anew.
I'm the guy who helped port the gaim-encryption plugin FROM Linux over TO Win32. (The opposite of the article and this topic, I know). But, after I sent the patches back up to the maintainer, he was able to easily carry it in his source tree.
I used Cygwin and MingW to handle the compilation with his original autoconf, etc. build environment. Of course, there was the requisite GTK+ libraries, etc. that went along with it too. But the magic was MingW and Cygwin.
Perhaps this could give the various developers some insight that "it really can be done".
--
3. Don't forget to enjoy!
>There are too many libraries that WINE simply doesn't support without linking against MS' DLLs...
True enough, but remember this article was directed at people trying to port their own code from Win32 to Linux. WINE should at least provide a good starting point. They don't *have* to use MS's DLL's.
But the real reason IBM doesn't deal with porting GUI-based code is that they're not interested in desktop Linux. They're talking about porting command-line based code only.
And the previous poster's point about buying a cheap X86 box rather than run a POWER-based Linux desktop misses the real value of a POWER WINE port. The ability to port WIN32 code to MacOS. I've had to resort to running my WIN32 code on Linux under WINE and accessing it via X-windows from OS/X - which, believe it or not, works fairly well. Then again, I've avoided using MFC or any MS DLL's.
Posted from my Android phone. Oh, I can change this? There, that's better...