Porting a large C project from unix to windows

This is a discussion on Porting a large C project from unix to windows within the C Programming forums, part of the General Programming Boards category; So, I have a large C project that was built entirely on Unix (Solaris 9 I believe). me and several ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    41

    Porting a large C project from unix to windows

    So, I have a large C project that was built entirely on Unix (Solaris 9 I believe). me and several others have begun to revisit it because their was some interest in a windows build.

    none of us have done this with a project of such size, so for starters, has anyone ported something from unix to windows and could maybe give me some pointers or how they did it.

    our first step on our plan was to decide on a compiler/dev environment.

    it seems that our options are MS Visual Studio, Cygwin, mingw/gcc, and Windows Services for UNIX (SFU).

    we are on a fairly short timetable so we want to rewrite as little code as possible.

    so, Deciding on a compiler.

    Another issue is that the code does use POSIX thread commands (pthread, etc)

    we would prefer to compile natively, not using some sort of layer between the executable and the OS. unfortunatly with the pthread calls in our code, this may not be possible.

    I believe both Cygwin and SFU do just that. Cygwin has a .dll that must be included in compiled code to work. I am not sure about SFU, any information about that would be greatly appreciated. It seems like it would be a good option but was developed to allow for UNIX compiled software to run on a windows machine with SFU, not any old windows box.

    mingw does have the ability to create native exes, but lacks the POSIX support.

    So, can anyone give me any more information, suggestions, knowledge on any of these compilers in this context. or any experience they have with this sort of thing, it is greatly appreciated.

  2. #2
    a guy with long hair Xupicor's Avatar
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    103
    I can't really help you that much, I'd guess it depends how non portable your code is. You may be interested in Open Source
    POSIX Threads for Win32
    though. I can assume it would be easier to use this than to rewrite threads completely to win32 way.
    Wiki says that SFU uses:
    Quote Originally Posted by http://en.wikipedia.org/wiki/Windows_Services_for_UNIX
    GCC 3.3 compiler, includes and libraries (through an MS libc)
    which would be plenty old right now.

    edit: If using MinGW, you'll probably want to use nuwen MinGW distro, to have pretty fresh version of GCC without the usual MinGW installation problems.
    Last edited by Xupicor; 09-22-2010 at 03:54 PM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Take a closer look to see exactly how much POSIX you actually need.

    Are they just threads, or are they relying on specific POSIX behaviour?
    If the usage is simple, and you only need a few functions, then writing your own wrappers around equivalent win32 functions should be considered.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    MSYS is an alternative to cygwin as far as a build environment goes. It ties in with MinGW but provides GNU tools and a unixish filesystem, if you need that kind of stuff for building the project.
    Consider this post signed

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    If the only POSIX functionality you are using is pthreads, then just use the pthreads for Windows library. My company does this, and it works very well.
    bit∙hub [bit-huhb] n. A source and destination for information.

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    41
    I toyed with the pthreads library and got some quick stuff I wrote up working, but Im honestly not sure whats posix compliant and whats not... is there any list of posix only functions?

  7. #7
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Quote Originally Posted by somekid413 View Post
    I toyed with the pthreads library and got some quick stuff I wrote up working, but Im honestly not sure whats posix compliant and whats not... is there any list of posix only functions?
    Check here for a list of the POSIX functions.
    bit∙hub [bit-huhb] n. A source and destination for information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 18
    Last Post: 10-04-2008, 06:50 AM
  2. Windows or Unix environment
    By ghe1 in forum Windows Programming
    Replies: 5
    Last Post: 02-19-2002, 11:37 AM
  3. C in Windows comparing Unix & Linux?
    By Hee Jeong in forum Windows Programming
    Replies: 1
    Last Post: 01-16-2002, 03:03 AM
  4. UNIX fork() equivalent in Windows
    By argon in forum Windows Programming
    Replies: 2
    Last Post: 01-04-2002, 01:56 PM
  5. unix, windows
    By stef in forum C Programming
    Replies: 3
    Last Post: 09-14-2001, 04:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21