gcc is not found when the Makefile is executed by Travis-CI

2

I have a C project in GitHub and I'm trying to build it with Travis-CI, but the following error is always displayed:

Using worker: worker-linux-9-2.bb.travis-ci.org:travis-linux-2
$ export CC=gcc
git.1
$ git clone --depth=50 --branch=someDevs git://github.com/luizfilipe/ffb-cglib.git     luizfilipe/ffb-cglib
Cloning into 'luizfilipe/ffb-cglib'...
remote: Counting objects: 114, done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 114 (delta 27), reused 80 (delta 12)
Receiving objects: 100% (114/114), 2.53 MiB | 0 bytes/s, done.
Resolving deltas: 100% (27/27), done.
Checking connectivity... done.
$ cd luizfilipe/ffb-cglib
git.3
$ git checkout -qf f76cd622418a75003d1aa6326c38039c1f556ee8
$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ make
gcc -c -pendantic examples/environment/main.c -I/usr/bin/Mesa-5.0/include -g
make: gcc: Command not found
make: *** [main.o] Error 127
The command "make" exited with 2.
Done. Your build exited with 1.

Reading the error I noticed that gcc was not found, but the .travis.yml file is configured as below:

language: c
compiler:
   - gcc
script: make

The Makefile of the project is:

# Variables
MESA = /usr/bin/Mesa-5.0
PATH = examples/environment/main
EXAMPLE_ENVIRONMENT = examples/environment/main.c
INCPATH = -I$(MESA)/include
LIBPATH = -L$(MESA)/lib
LIBS        = -lglut -lGLU -lGL -lm
CFLAGS  = $(INCPATH) -g
LFLAGS  = $(LIBPATH) $(LIBS)

# Main targets
all: main.o
    $(CC) -o $(PATH) main.o $(LFLAGS)

# Source targets
main.o: $(EXAMPLE_ENVIRONMENT)
    $(CC) -c -pendantic $(EXAMPLE_ENVIRONMENT) $(CFLAGS)

Any idea what might be causing the error?

    
asked by anonymous 15.02.2014 / 19:03

1 answer

2

It is good practice to make a Makefile that does not depend on a particular compiler. In your case, you explicitly used gcc to compile, always. Instead, get the default C compiler from the environment variable CC . If you notice the log, travis moves this variable in the beginning.

The Makefile looks like this:

# ...

# Main targets
all: main.o
    $(CC) -o $(PATH) main.o $(LFLAGS)

# Source targets
main.o: $(EXAMPLE_ENVIRONMENT)
    $(CC) -c -pendantic $(EXAMPLE_ENVIRONMENT) $(CFLAGS)

Another error is in resetting the PATH variable. It is used by the system to locate where the executables are. The moment you've changed, the system will no longer be able to find the absolute path to gcc . Simply rename the variable and everything should work.

    
15.02.2014 / 19:08