How to compile a C program?

I have not done C for a long time. I would like to compile this program , but I have no idea how to proceed. It looks like the makefile references GCC a lot, and I never used GCC.

I just need an executable that will run in windows.

+4
source share
7 answers

You may need to install cygwin or mingw, which are UNIX-like environments for Windows.

When downloading / installing cygwin or mingw, you will have the opportunity to download and install some additional functions; you will need the following:

  • gcc (try version 2.x first, not 3.x)
  • Binutils
  • GNU make (or gmake)
+9
source

If it requires gcc and you want it to run on Windows, you can download Cygwin.

This is basically an emulator for the GNU / Linux type for Windows. It works with DLL emulation.

http://www.cygwin.com/

+4
source

To compile this program, you need a C compiler. It does not have to be gcc, although you have already been provided with a makefile configured to use gcc. The easiest way to do the following:

  • Install cygwin
  • Open cygwin command prompt
  • go to the directory where you have the makefile
  • type 'make'
  • This should compile your program.

If you are not comfortable using the command line tools, you can download the free version in MS Visual Studio and import the source files into a new Visual Studio project. This way you will not need to install cygwin and use gcc, but you will need to know how to create projects and run programs in Visual Studio.

+4
source

You almost certainly don't need all cygwin to compile using gcc. There are many standalone gcc clones for Windows, such as gcw .

+3
source

If this is a reasonably portable C code (I haven't looked at it), you can simply ignore the included Makefile and feed the source to any compiler you want to use. What happens when you try to do this?

+3
source

Dev-C ++ provides a simple but enjoyable IDE that uses the Mingw gcc compiler and provides Makefile support. Here are the steps that I used to create the above code using Dev-C ++ (i.e., this is "practical")

After downloading the original zip from NIST, I

  • downloaded and installed the beta version of Dev-C ++ 5
  • created a new empty project
  • added all .c files from sts-2.0 \ src

Then in the "Project Settings" section

  • Added -lm in the Linker column under Options
  • added sts-2.0\include to Include directories in directories
  • set the Executable and Object directories to the obj directory in the "Build Options" section

and then click OK to close the dialog box. Go to Run> Compile and let it spin. After a minute, you can find the executable in the sts-2.0\obj directory.

+1
source

Firstly, there is little chance that a program with only make files will be built with a visual studio, if only because the visual studio is not a good C compiler from the standard POV (mathematical functions, in particular, are very poorly supported in MS compilers), It may be possible, but it will not be easy, especially if you are not familiar with C. You really should stick with makefiles instead of trying to import the code into your own IDE - this kind of scienfitic code is clearly intended to be compiled from the command strings. This is a test suite, so randomly trying randomly is NOT a good idea.

You must use mingw + msys to install it: mingw will provide you with compilers (gcc, etc.), and msys will provide a shell for the make file to run correctly. Unlike another poster, I would advise you not to use gcc 2 - I do not see any point in this. I usually use gcc 3 (and even 4) for Windows to create scientific code, it works well when the code is unix-like (which is the standard platform for this type of code).

0
source

All Articles