views:

406

answers:

4

Hello, I'm trying/thinking of making CppCMS - C++ Web Framework project little bit more cross platform.

Today I can easily support Linux, OpenSolaris, FreeBSD and even Cygwin. But when it comes to Native Windows it becomes really painful:

The overview of the situation:

  1. I'm POSIX/Linux developer and I'm barely familiar with Native Windows development tools like Visual Studio and Win32 API. However I do some work for this platform so I understand the limitations and the fact that Windows is totally different world.
  2. This is web project that uses APIs that popular in Unix world, like: CGI, FastCGI and SCGI that implemented in most UNIX web servers; but I understand that I would not be able to use it with IIS because it does not support FastCGI over TCP/IP (only Windows pipes).

    So even when it would work it would probably run only with Windows port of Apache.

  3. I relay heavily on POSIX API:

    • Pref-forking allows be keep high survivability in case of crashing (not supported under windows) so this feature would be missing.
    • I use some file-locking facilities (but I can probably give them up without forking)
    • I have intensive use of native pthreads, even I can replace them with Boost.Thread
  4. I probably would never be able to support Visual Studio (maybe 2010 with C++0x support), because I relay on C++0x decltype/auto feature or typeof/__typeof__ extension that is supported by most compilers I worked with: gcc, intel, sun studio. (To be honest: I can work without them but it makes the life much easier to framework user.
  5. I relay heavily on autotools and I can't replace them with CMake, bjam or friends, because when it comes to support of internationalization, cross copiling, package management, they just does not give me a solution.
  6. There are many annoying points like missing gmtime_r, or localtime_r under windows and many others that just require from me to rewrite them or replace them with 3rd part libraries.
  7. There are still many "UNIX like" libraries that ported to Win32 like: iconv, gcrypt and some others that are barely ported like libdbi that have many limitations on windows.

Bottom line:

There is lots of non-trivial work to do, and even when it would be complete, it would probably work only with MingW tools and not "native" tools that Windows programmers are familiar with.

So, my questions are:

  • Does such MingW port worth an effort? Would this help to build bigger community?
  • Does anybody have experience on how painful porting big projects from POSIX environment to Win32 API is?
  • Would it be useful for Windows developers at all?

Edit:

It is also important for me to understand, how many of windows developers prefer to use Open source development tools, MingW over Microsoft development solutions like VS.

Edit #2: Clearification about "native" windows solusions and IIS.

In fact, running framework with IIS is really hard problem. I explain:

  • The project relates to standard web server API as FastCGI or SCGI that allows to accept many requests over sinlge socket. Thus, on application side, I accept new request proceed it and returs the ansver. Sometimes several threads process serveral requests.

    Thus, implementing one or two standard protocols I open communication with any existing server: Apache, lighttpd, nginx, cherokee... or any other servers; with small exception of IIS

  • IIS has implementation of FastCGI, but... It supports only 1 connection per local process only that controlled by web server...

So... there is absolutly no standard way to connect my application to IIS.

Please note, I implement standard Web server API, I do not implement Neither IIS propriatry ISAPI nor Apache propriatry API, even the second is more important as for targeting UNIX world.

So, just Windows IIS Web world is just not really ready for cooperation for such project, so if anybody would use it under Windows it would use it with more open web servers.

+2  A: 

You should base your decision on user demand. Have users ever requested using the framework on Windows? If so, did they explain why they wanted to use Windows (e.g. what additional constraints they had, what webserver they wanted to use, etc.)?

Typically, Windows users do expect that things work the Windows way. That means Visual Studio support, IIS support, MSI installer, and so on. If something still feels like being Unix, I would rather use Unix proper, instead of fighting with a half-working port.

Martin v. Löwis
But, as far as I understand lots of windows developers use MingW; am I wrong?
Artyom
That's true about "windows-way" the things are expected to work. I *hate* it when I have to do e.g. cygwin magic or jump through other hoops in order to even compile a "cross-platform" application.
macbirdie
@Artyom: People had been using MingW when nothing else was around for no cost. Now Microsoft provides free (as in beer) copies of VS which are provide most functionality that you needs, so people turn away from MingW, in particular as MingW also has limitations.
Martin v. Löwis
+1  A: 

As a windows client app developer it sort of hurts me that the development environment division currently is essentially Win32 and everything else and that they are mostly incompatible. That's why I'm preparing to move to MinGW for my personal windows app projects and to try to make them cross-platform.

I would suggest gradually moving to more cross-platform libraries like, as you suggested, refactoring pthreads to boost::thread, or going from fork() to multi-process with IPC, probably also using boost's facilities. Date/time stuff can be dealt with Boost libs as well. As for database support, there are

Microsoft compiler support is not that important I think, as MinGW provides a decent build environment with all the IDEs that support it, Eclipse CDT and Dev-C++ being among the most popular. But if you are going to make your project msvc-compatible, make sure users will be able to use Express editions of Visual Studio 2010 (as soon as thay come out) - that way no one will have to fork out for a Visual Studio 2010 (upgrade) just to use your project and there will be no problem for you to require the latest in Microsoft technology.

Most likely you won't avoid some amount of ifdefs for a code base of your project's size, but surely the effort might be worth it, if not only for gaining valuable experience and expanding the community with a few new happy and grateful members.

macbirdie
>> the development environment division currently is essentially Win32 and everything else and that they are mostly incompatible << Yes, this is the biggest problem, because, I have no problems to support everything else but Win32... and in order to support it I must learn lots of Win32 API. Even replacing simple /dev/urandom drives me crazy under windows.
Artyom
A: 

Your saying that you can support Cygwin quite easily reminds me that I've seen commercial Windows software that simply bundled in cygwin1.dll to support some originally-Unix code. If adding cygwin1.dll to your installer is all it takes, try it out.

erjiang
The cygwin DLL is GPL (not LGPL) licensed. Therefore those commercial apps must also be GPL licensed. Not many commercial organisations go that route.
anon
Red Hat sells Cygwin licenses that let you avoid being bound to GPL: http://www.redhat.com/services/custom/cygwin/
erjiang
A: 

I think you only have to look at the questions asked on SO to work out that MinGW users on Windows (of which I am one) are in a minority in the development community - the vast majority of Windows developers are using MS tools. Anyway, the compiler is only half (or less) of the issue - if your architecture depends on forking lots of processes, using MinGW is not going to help you. My advice is, if you really want to do cross platform development:

  • look at how Apache do it
  • consider using the Apache libraries as your base
  • don't use very new or compiler-specific language features
  • use multi-threading rather than multi-process
anon