I know this question has been asked several times and I took a look at many of them like
- Running linux gcc-compiled program under windows
- How can I compile C files into an executable (.exe) file?
Unfortunately, none of them worked for me.
My situation
I've installed Ubuntu and Windows on my Notebook.
- Let's say I developed a simple
"Hello,World!"
program using a text editor in c. - In Ubuntu, I've compiled it using GCC
$ gcc -o hello.out -g -Wall -pedantic hello.c
- I executed it
'./output.out'
- And got the result
Hello, World!
What I tried
So I kind of cross-developed here. I switched to Windows and kept going.
Now, I try to make it an executable file in order to run it on Windows. I know Windows can't handle '$ ./output.out'
, alright, let's make it an executable then.
Under Windows, I've
- installed cygwin
- In Cygwin, I compiled it using GCC
$ gcc -o hello.exe -g -Wall -pedantic hello.c
Note: I wrote hello.exe instead of hello.out or hello.c
- In Cygwin, I executed it
'$ ./output.exe'
- And got the result
Hello, World!
Note: At this point, it even works with my Shell under Windows because I installed Cygwin and set up my PATH etc. This means I can open my command line, go to the directory in which 'hello.exe'
is located and execute it by typing '> hello.exe'
I thought that would be it, so I took hello.exe'
and moved it to another notebook (not my local machine). I tried to execute it but it didn't work.
At first, I got an cygwin1.dll missing message. After fixing it, another error appears.
What I'm trying to accomplish
To make a long story short: The reason I wrote so much is that I want to give you a detailed look of my situation.
Basically, I'm trying to create an executable c file, which any Windows User could execute without having any development tools.
In Eclipse and Java, you could simply export your program making it a runnable -jar file. All the User has to do is install the latest Java SE version to get it running.
Additionally, I tried to compile my program in Visual Studio but that didn't work either.
Any suggestions? Thanks a lot!