0

I want to write a program which should be able to communicate over a network between Windows and CentOS machines.

Now, my problem is that I do not have access to a centOS (6/7 x64) machine to have it done / tested. Is there a way of building it on a Windows machine so that it will be compatible on centOS too? It is going to have a very simple command line interface so there's no need for a GUI compatibility.

tripleee
  • 175,061
  • 34
  • 275
  • 318
Cajuu'
  • 1,154
  • 2
  • 19
  • 50
  • You can use something like Amazon AWS / Elastic Cloud to do this but it may be too much just for a single program. – ForceBru Mar 12 '15 at 19:50
  • This question appears to belong on another site in the Stack Exchange network because its not about programming or development. Perhaps you should try [Software Recommendations Stack Exchange](http://softwarerecs.stackexchange.com/). You should ask about Virtual Machine software or Emulator software. Be sure to thoroughly specify your requirements. – jww Mar 12 '15 at 19:50
  • [cross compiling](http://stackoverflow.com/questions/897289/what-is-cross-compilation) from Windows to CentOS can help, but it's not easy – phuclv Mar 13 '15 at 08:24

3 Answers3

1

If you mean to compile a file on Windows and then have the executable run on Centos then the answer no (see below).

If you mean to write code on Windows that you can move to a Centos box, compile and run, then the answer is yes. To do this you need to insure that you write code that is at least posix compliant. Note that there are a number of cross-platform frameworks if you want graphical interfaces (like QT).

N.B. -- It should be possible to cross-compile if you want to be able to move the executable from a windows box to a Linux box. You will (probably) need to use gcc (mingw) as you compiler on Windows.

thurizas
  • 2,473
  • 1
  • 14
  • 15
1

My ELLCC cross compilation tool chain can compile C and C++ programs targeting Linux and Windows systems on both Windows and Linux hosts. Pre-built binary packages are available for download.

It's pretty easy to use. Here is an example of building a hello world program for Linux and Windows on a Linux host:

[~/ellcc/examples/hello] dev% ~/ellcc/bin/ecc -target x86_64-linux-eng main.c 
[~/ellcc/examples/hello] dev% ./a.out 
hello world
[~/ellcc/examples/hello] dev% ~/ellcc/bin/ecc -target x86_64-w64-mingw32 main.c
[~/ellcc/examples/hello] dev% ./a.exe 
fixme:winediag:start_process Wine Staging is a testing version containing experimental patches.
fixme:winediag:start_process Please report bugs at http://bugs.wine-staging.com (instead of winehq.org).
hello world

and the same program on a Windows system:

C:\ellcc\examples\hello>c:\ellcc\bin\ecc -target x86_64-w64-mingw32 main.c
C:\ellcc\examples\hello>.\a.exe
hello world
C:\ellcc\examples\hello>C:\ellcc\examples\hello>c:\ellcc\bin\ecc -target x86_64-w64-mingw32 main.c
C:\ellcc\examples\hello>.\a.exe
hello world
C:\ellcc\examples\hello>

ELLCC targets a variety of Linux systems including ARM, Mips, PowerPC and X86 systems as well as 32 and 64 bit Windows systems.

Richard Pennington
  • 19,673
  • 4
  • 43
  • 72
0

The best solution is probably to install CentOS on a virtual machine such as VirtualBox and use that for test and development.

Lars Ljung
  • 375
  • 2
  • 6
  • I can't. I tried to install centOS on VirtualBox and it didn't work. More, I can't even install centOS as a second OS because of my laptop issues. More, I'm only running on a 2GB RAM machine 2.2Ghz so my laptop will run slow even if I'd be able to do so(running on a VM). – Cajuu' Mar 12 '15 at 19:47
  • 1
    @Alexander did you install one with GUI? if so, may be you can drop it. pure cli could accelerate a lot. – Jason Hu Mar 12 '15 at 21:18