Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: how much work it is to change source code to work with linux?

Author: Russell Reagan

Date: 03:02:07 06/23/04

Go up one level in this thread


On June 23, 2004 at 05:10:07, Uri Blass wrote:

>I ask because Dieter told me in an email that I can install Linux, where I can
>get the newest Intel compiler and it is free for non commercial use.
>
>A related question is if I can see examples of code that work under windows and
>descreption of changes that are done to compile it under linux.
>
>Another question is if a program that is compiled under linux can work under
>interfaces like winboard that are based on windows.
>
>I guess that there should be no problem and as far as I know tord writes gothmog
>under linux and it runs under winboard.
>When I think about it maybe I need some #if #def to make it work.
>
>Uri

All you have to do for your program to work under Linux is make sure it is
"standard" C or C++. If you use any functions that are specific to Windows then
your program will not compile on Linux without modifications (ex. if you have
#include <windows.h>).

As long as your program is in standard C, and it supports the Winboard protocol,
it should also work in XBoard in Linux. I think you have to add Zippy to XBoard
in Linux if you want to play on ICC. Remember, a protocol like the
Winboard/XBoard protocol has nothing to do with the operating system. The reason
for using a protocol in this case is so that the protocol can be used in any
operating system.

What Tord does is slightly different. He wrote his program for the Mac, I
believe (Mac OS X is unix), so his program probably compiles fine in Linux. In
other words, he went from Unix to Windows. You are going from Windows to Unix.
There is a set of programs called Cygwin which allows people to use the same
kinds of programs that they use in Linux (text editors, programming languages,
and all sorts of useful command line programs). He must have asked someone to
compile his program using the C compiler that comes with Cygwin. If you do that,
your program needs an extra .dll file to run in Windows, but the advantage is
that you don't have to make any changes.

One good way is to just write your program using standard C, and then use the C
preprocessor (#ifdef, #elif, #endif, etc.) when you must use something that is
not standard.

Another option is to use a portable third party library. For instance, if you
want to add multi-threading to your program, there are portable thread libraries
that you can use, such as pthreads and many others. You just write your code to
use pthreads, and then you install pthreads in Windows and in Linux (it will
already be installed in Linux), and your code will compile fine under both Linux
and Windows. There are portable libraries for just about anything you could want
(threads, networking, etc.), so it is possible to have the same code compile
without modification under both Windows and Linux.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.