6

I haven't touched C for years but need to compile some C source code for Windows 7 64. The source comes with a makefile. Can someone please recommend a C compiler with make?

PS:

The make file:

POSTFIX="_amd64"
CC = CC="cc -Wall"
RANLIB=RANLIB="ranlib"
INSTALLDIR=/usr/local/bin
LIBINSTALLDIR=/usr/local/lib

VERSION=4.12
DATE=10/10/10

PROGRAMS=bib2xml ris2xml end2xml endx2xml med2xml isi2xml copac2xml \
    biblatex2xml ebi2xml wordbib2xml \
    xml2ads xml2bib xml2end xml2isi xml2ris xml2wordbib modsclean

all : FORCE
    cd lib; make -k $(CC) -k $(RANLIB); cd ..
    cd bin; make -k $(CC) -k VERSION="$(VERSION)" -k DATE="$(DATE)"; cd ..

clean: FORCE
    cd lib     ; make clean ; cd ..
    cd bin     ; make clean ; cd ..
    cd test    ; make clean ; cd ..

realclean: FORCE
    cd lib     ; make realclean ; cd ..
    cd bin     ; make realclean ; cd ..
    cd test    ; make realclean ; cd ..
    rm -rf update lib/bibutils.pc

test: all FORCE
    cd lib    ; make test; cd ..
    cd bin    ; make test; cd ..

install: all FORCE
    cd lib ; make -k LIBINSTALLDIR=$(LIBINSTALLDIR) install; cd ..
    sed 's/VERSION/${VERSION}/g' packageconfig_start > lib/bibutils.pc
    @for p in ${PROGRAMS}; \
        do ( cp bin/$$p ${INSTALLDIR}/$$p ); \
    done

package: all FORCE
    csh -f maketgz.csh ${VERSION} ${POSTFIX}

deb: all FORCE
    csh -f makedeb.csh ${VERSION} ${POSTFIX}

FORCE:
cs0815
  • 16,751
  • 45
  • 136
  • 299
  • I like [GnuWin32](http://gnuwin32.sourceforge.net/). You can use its `make` with any compiler. – pmg May 12 '11 at 13:43

5 Answers5

13

Since everyone here is oblivious to your clear 64-bit statement, I'll give a correct answer:

  1. If the makefile is an Nmake makefile, you can install the Visual Studio Express for Windows Desktop, open a command prompt from the start menu (choose the one targetting 64-bit Windows), cd to your project's directory, and run nmake. You'll need to modify the makefile to call cl and link.

  2. If the Makefile is a MinGW makefile, you will need mingw-w64's toolchains targetting Win64 (note also 32-bit toolchains are provided). I recommend the official builds provided through an installer or the ones installable from MSYS2 (see point 3). Install, open the MinGW-w64 command prompt, cd to your projects directory, and run mingw32-make.

  3. If the Makefile is a Unix/MSYS makefile, I suggest using MSYS2. You can use the above toolchain, or do pacman -S mingw-w64-x86_64-gcc to install a toolchain from the MSYS2 shell. Be sure to either add /mingw64/bin to PATH or launch from the "MSYS2 MinGW-w64 64-bit" shortcut to use it. Note you can use MSYS2 as a package management tool only: install any dependency you want (there are tons of 3rd party library binaries ready for use) and just add the <MSYS2 root>/mingw64/bin directory to PATH and call the compiler from anywhere.

  4. If the project uses Unix functionality (like fork() or other Unix system calls), you can use 64-bit Cygwin, install its compiler, and link with the Cygwin dll. This is not recommended as there is a performance (well, relative to porting the code to Win32 APIs) and license penalty (The Cygwin DLL is GPL, which forces your program to be licensed in a GPL-compatible way).

These are four ways of compiling a C source file for 64-bit Windows with free tools. If you are a student, you can probably use the following ways as well:

  1. Download Visual Studio Professional from Dreamspark (if your university/college/school has an agreement with Microsoft for this) and use that. Pretty much equivalent to point 1 except if you use stuff like MFC/ATL and/or VS plugins, which don't work in the express version.

  2. Download the Intel compiler from their Education offerings website. Requires Visual Studio Professional from point 5 though. You'll need to modify the Makefile to use the Intel compiler though.

  3. Download the LLVM/Clang compiler from here (the Windows snapshot builds) and use it in conjunction with point 5. You'll need to modify the makefile to call clang.

I know this is more than what you asked for, but my high-rated answers need to be complete, right?

rubenvb
  • 74,642
  • 33
  • 187
  • 332
  • Thanks for that. I have added the make file (see PS). Given this which of your points does apply? Thanks! – cs0815 May 13 '11 at 11:20
  • I'd try the MSYS one (number 3). There's `sed` and `csh`. The first is in the MSYS package I linked, the second I don't know, see and try. – rubenvb May 13 '11 at 16:55
  • Thanks. I set the path but get: "make[1]: cc: Command not found". mingw does come with gcc do i have to edit something. some linux sites wrote that cc is only used if there is no gcc ... any ideas? Thanks. – cs0815 May 16 '11 at 08:45
  • 1
    You will need to edit your makefile so that `CC="gcc -Wall"` and hope it works. You *might* have to rename `csh` to `sh` or `bash`, but I don't know if that is necessary or will work even if you replace that. – rubenvb May 16 '11 at 12:26
  • @rubenvb Excellent answer. Please could you clarify this though: "Install, open the MinGW-w64 command prompt, cd to your projects directory, and run mingw32-make." Does this make a 64-bit executable? If not, is there a `mingw64-make` or similar? – sdgfsdh Jul 05 '16 at 16:57
1

You could use Visual C and look at nmake

see: How to use makefiles in Visual Studio?

Community
  • 1
  • 1
rurouni
  • 2,315
  • 1
  • 19
  • 27
1

You could try MinGW to have makefiles similar to GCC ones.

Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
1

Have a look at http://www.cygwin.com/

ColWhi
  • 1,077
  • 6
  • 16
1

Code::Blocks comes with a built in Mingw environment, which should handle makefiles just fine.

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173