smwikipedia
smwikipedia

Reputation: 64205

Can I compile and run a linux app C++ source on Windows?

I have source code for a linux application. It seems I can compile it on windows with CygWin. My question is, after compilation, can I run it on Windows?

Upvotes: 0

Views: 161

Answers (3)

Kiran Kamath
Kiran Kamath

Reputation: 1

Cygwin/mingw(http://www.mingw.org/) should have most of the tools you need to build the binary. Once the build succeeds, you can run the binary (only) on windows.

Upvotes: 0

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81684

The simple answer is yes; if you can compile a Linux application with Cygwin, then the compiled application will run on windows. Cygwin provides windows implementations of many unix system functions and libraries.

Upvotes: 2

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137398

Depends totally on what APIs you use. If you stick to C standard library things, like <stdio.h>, <stdlib.h>, etc. then yes, you can just compile and run on either OS. Or for C++ apps, there is the Standard C++ Library, which any OS / development environment should provide.

If you use any OS-specific APIs, then of course it will not be compatible with another OS. There are libraries however, like APR that try to abstract out the OS-specific bits.

From a casual glance at the code you've linked to, it appears to not use any OS-specific APIs. However:

Note that this code requires the Gnu Scientific Library, http://www.gnu.org/software/gsl/

you'll need to get that library installed as well.

Upvotes: 2

Related Questions