gcc is not found when Makefile is run by Travis-CI

Asked

Viewed 472 times

2

I have a C project on Github and I’m trying to build with Travis-CI, but it always shows the error below:

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 the gcc not found, but the file .travis.yml 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?

  • The error can also be checked in #18

1 answer

2


It is good practice to make a Makefile that does not depend on a specific compiler. In your case, you explicitly used the gcc to compile, always. Instead, take the standard compiler of C of the environment variable CC. If you notice in the log, the Travis arrow that variable at the beginning.

The Makefile will look 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 variable PATH. It is used by the system to locate where the executables are. The moment you have changed, the system will no longer be able to find the absolute path to the gcc. Simply rename the variable and everything should work.

  • I updated the files and the problem still persists, I also updated the question with the error and the new files, some idea?

  • @Luizfilipe, updated the answer. Just be careful updating questions to avoid discounting existing answers

  • I had not noticed the error! Thanks for the warning! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.