0

I am having trouble compiling using make in windows 7 with gcc and the gsl library. It occurs only when using make (when I type the compilation commands manually into the cmd line, it compiles correctly). I found some posts where people had similar errors from gcc, but none where it worked when typing normally, but not when using make. The contents of my Makefile are shown below:

#Compiler
COMP=gcc
# Compiler Flags.  -Wall turns on all warnings
FLAGS=-Wall
# GSL include file dir
INCLUDES=GnuWin32/include
# GSL Libraries directory
LIB=GnuWin32/lib
# Library Flags
LFLAGS=-lgsl -lgslcblas -lm
# Target Program
EXE=ex2.1.exe
# Dependencies needed for $(PROGRAM)
OBJ=ex2.1.o
# List of source files for objects
SRC=ex2.1.c
# List with types of files to be cleared by clean:
TRASH=*.exe *.o
# I/O files to be cleaned with 'very clean' target
#IOFILES= *.dat *.out *.csv *.mod

all: $(SRC) $(EXE)

$(EXE): $(OBJ)
    $(COMP) -L/$(LIB) $(OBJ) $(LFLAGS) -o $(EXE)

$(OBJ): $(SRC)
    $(COMP) -I/GnuWin32/include -c ex2.1.c
    #$(COMP) -I/$(INCLUDES) -c $(SRC)

clean:
    del $(TRASH)

If I type make with only the ex2.1.c present in the directory, I get the following output and error:

gcc -I/GnuWin32/include -c ex2.1.c
gcc: error: CreateProcess : No such file or directory
make: *** [ex2.1.o] Error 1

However, if I first type "gcc -I/GnuWiun32/include -c ex2.1.c", ex2.1.o is created successfully with no error. If then type 'make' I get the following output/error:

gcc -L/GnuWin32/lib ex2.1.o -lgsl -lgslcblas -lm -o ex2.1.exe
gcc: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found
compilation terminated
make: *** [ex2.1.exe] Error 1

But if I manually enter "gcc -L/GnuWin32/lib ex2.1.o -lgsl -lgslcblas -lm -o ex2.1.exe" then the executable compiles and runs like it should, so the problem seems to be with how make is calling gcc? My PATH variable contains the paths to both make.exe as well as gcc.exe, so I am not sure what I do not set up correctly. Does anyone have an idea of what may be wrong? Thanks.

Wigwam
  • 1
  • 1
  • Maybe [this link](http://mingw-users.1079350.n2.nabble.com/fuse-linker-plugin-td6954234.html) helps? It is not clear to me whether you are running in an MSYS shell or regular DOS shell. – Reinier Torenbeek Apr 10 '13 at 02:23
  • Thanks, but that link didn't help too much since I am using regular DOS shell and I haven't moved anything around in the gcc directory. I even tried adding a copy of gcc.exe to the folder in which I am trying to compile, and it still says it is not found. – Wigwam Apr 10 '13 at 23:31
  • Could you try the following: in your DOS shell, type `where gcc` and post the result. Then in your makefile, add `$(info where gcc = $(shell where gcc))` and capture the output. That command should give information about whether or not the shell used by make can find `gcc`, and where. – Reinier Torenbeek Apr 11 '13 at 02:44
  • @ReinierTorenbeek When I type 'where gcc' in the DOS shell, I get: C:\Python27\Scripts\gcc.exe C:\MingGW\bin\gcc.exe C:\Program Files\gfortran\bin\gcc.exe C:\MinGW\msys\1.0\bin\gcc.exe After adding that command into my makefile and entering 'make' I get: where gcc = C:\Python27\Scripts\gcc.exe C:\MinGW\bin\gcc.exe C:\Program Files\gfortran\bin\gcc.exe C:\MinGW\msys\1.0\bin\gcc.exe And I also get the first error mentioned in the original post. It appears to me like the shell used by make is seeing the same paths to gcc, no? – Wigwam Apr 11 '13 at 15:43
  • Hmm, it looks like they are seeing the same paths indeed, but I am somewhat surprised that it finds multiple `gcc`s in the first place. What I would try for a test would be to verify which of the `gcc`s is the one that works for you in the DOS shell, and then hardcode that `gcc` with its full path in your makefile, for example `COMP:=C:\Python27\Scripts\gcc.exe`, then run `make` again. – Reinier Torenbeek Apr 11 '13 at 17:07
  • @ReinierTorenbeek Hey Reinier; sorry for the delayed response. Long couple of weeks. Thanks for your help. In the process of trying to figure out which gcc it was using, I found the broken (or at least not compatible) one that it was referencing and failing with (the gcc.exe in C:\Program FIles\gfortran\bin\gcc.exe). I just renamed it and replaced it with the working version from the MinGW directory. Now, typing 'make' works like it should. Thanks again! – Wigwam Apr 22 '13 at 22:55

0 Answers0