C: Running Unix configuration file on Windows

I would like to port several applications that I use on Linux for Windows. In particular, I worked on wdiff . A program that compares differences in a word from two files.

Currently, I have been able to successfully compile the program on windows through Cygwin. However, I would like to run the program natively on Windows, similar to the project: UnixUtils .

How can I port unix utilities in windows environment?

My guess: manually create the file. / configure so that I can create the appropriate makefile. Am I on the right track? Has anyone had experience porting GNU software to windows?

Update:

I compiled it on Code :: Blocks and got two errors:

  • wdiff.c | 226 | error: `SIGPIPE 'undeclared (first use in this function)

  • readpipe.c: 71: undefined reference to `_pipe '

  • readpipe.c: 74: undefined reference to `_fork

This is a linux signal that is not supported by Windows ... equvilancy?

  • wdiff.c | 1198 | error: `PRODUCT 'undeclared (first use of this function) |

this is in the configure.in file ... hardcode will probably be the fastest solution ...

Result:

MSYS took care of the configuration issues, however MinGW was unable to resolve posix issues. I am trying to use pthreads as recommended by mrjoltcola. However, after a few hours, I could not compile and link it using the provided libraries. I think that if it worked, that would be the solution I was. Special mention to Michael Madsen for MSYS.

+7
c windows gnu porting
source share
4 answers

You can take a look at MinGW (and MSYS), which are similar to cygwin, but gcc creates their own Windows executables. However, since Unix emulation is not as good as cygwin, you may need to tweak your code.

+2
source share

Yes. If you stick to the C standard library and POSIX functions, most of them are available on Windows. You just need to find implementations. There are implementations of things that do not require Cywgin or MinGW (for example, the pthreads package, etc.)

In addition, there is a wonderful book written in the style of W. Richard Steven Advanced Proramming on UNIX, and Windows System Programming by Johnson Hart. He has a 4th edition. It focuses on system programming, there is no graphical interface.

http://www.amazon.com/Windows-Programming-Addison-Wesley-Microsoft-Technology/dp/0321657748

This is the best book I know for UNIX programming moving to Windows.

+3
source share

Always try to adhere to standards even when porting applications. POSIX-compatible compilers exist on Windows / Linux. You can try mingw. It has the full tooling binding needed to create a standard POSIX application (also GNU Linux). Check out Dev-Cpp, which makes work easier.

0
source share

MinGW is the easiest way to get gcc and its associated binary utilities (including gdb) on a Windows PC. It includes header files and import libraries so you can use your own Windows APIs. If you want a more integrated IDE development environment, you can download Microsoft Visual Studio Express C ++ for free.

In any case, you probably have to convert some function calls to use Windows-specific APIs (if you need a book, I would also recommend the Hart book mentioned in mrjoltcola's answer). For simple command line tools, this conversion is usually not a huge deal, large porting nightmares tend to include GUI tools that have deep built-in dependencies on the GUI infrastructure provided by the OS.

0
source share

All Articles