1

I am new to C. What is the most simple way to execute a C program without an IDE?

I created my first C program und it runs flawlessly using my IDE Netbeans on Mac OS X. Now I need to make that program be "executable without IDE on Windows".

Also the requirement is only "Windows", no specific version. Which means I might have to support XP, Vista, 7, 8.

What is the most simple way to do so?

13
  • Do you mean to compile it without an IDE? Once it's compiled, you can run it on any computer just by double-clicking the .exe file. Commented May 28, 2014 at 13:00
  • Yes then I mean compile it. How can I compile my program to .exe? Commented May 28, 2014 at 13:01
  • Your IDE compiles the program (producing an .exe file) every time you click the Build button or run the program from within the IDE. Commented May 28, 2014 at 13:02
  • I found a unix executable under dist/Debug/GNU-MacOSX/bfs that runs in Terminal. How can I create a .exe for Windows? Commented May 28, 2014 at 13:10
  • 1
    So, do I understand right, you want to cross-compile on Mac, with Windows XP as cross compilation target (so it should run on later Windowses as well)? Commented May 28, 2014 at 13:17

2 Answers 2

1

As soon as you have built your app, it is a program you can run outside the IDE. You just need to find it. :) In NetBeans this will usually be under your project directory in a subdirectory called "dist". There will be an executable file in there which you can copy out to wherever you want.

Sign up to request clarification or add additional context in comments.

5 Comments

I have just build it, but I cannot find a .exe file. I am using Mac OS, do I have to build on Windows?
No, sorry I said exe when I should have said executable. You should be able to find the program NetBeans built by looking in the Project Properties, perhaps under Linker settings.
Yes I found it dist/Debug/GNU-MacOSX/bfs but that does not run under Windows, as I built under Mac OS right?
Right, so if you want to run on Windows you need to build on Windows. You can't (at least, not easily) build C programs for Windows machines where the build machine runs Mac OS. If you really want to try, it's called cross-compiling and some tools are here: crossgcc.rts-software.org/doku.php?id=compiling_for_win32
Thanks, I will try to build on Windows, hoping my Mac OS C code does not break.
1

Download MinGW here: http://sourceforge.net/projects/mingw/files/latest/download?source=files and install it. Then go to cmd (In Windows 8 - Windows key+R and type cmd in the window opened. In Windows 7 - search >> run >> cmd). After installing it and entering cmd type in the Command Prompt window (CMD) cd C:/MinGW/bin (when MinGW is on C drive which is the default path). After doing so type the following command: gcc -o X.exe Y.c when X is the name of the output file (what name you want the .exe file to be and Y is the name of the C file that must be inside of the BIN folder (C:/MinGW/bin by default). It should be compiled smoothly if it compiled in your IDE and then the .exe file would be in the BIN folder named X.exe (when X is what you typed in the CMD). Afterwards, you can close your CMD and do with the .exe file whatever you like.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.