我在github上有一个C项目,我正在尝试在Travis-CI中构建代码,但出现此错误:
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.
读取错误时,我注意到gcc
找不到该错误,但是.travis.yml的配置如下所示:
language: c
compiler:
- gcc
script: make
Makefile的配置如下:
# 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)
有什么想法吗?
更新:我只是切断了叮当声,使Makefile更不可知,我仍然遇到相同的问题。
问题是您对编译器进行了硬编码,然后要求travis针对两个编译器进行构建。这意味着travis将尝试使用gcc构建您的代码,然后再次尝试使用clang构建您的代码。您有两个选择,可以从您的计算机中删除clang作为编译器,.travis.yml
或者将makefile更改为与编译器无关。要更改您的makefile,只需将gcc的所有实例替换为$(CC)
还$PATH
包含查找可执行文件的位置。如果您将其覆盖,将无法找到任何东西。因此,您需要将$ PATH重命名为example_path之类的内容,例如
# Variables
MESA = /usr/bin/Mesa-5.0
example_path = examples/environment/
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 $(example_path)/main.o $(LFLAGS)
# Source targets
main.o: $(EXAMPLE_ENVIRONMENT)
$(CC) -c -pendantic $(EXAMPLE_ENVIRONMENT) $(CFLAGS)
您还需要在.travis.yml
文件中添加一个before_install部分以安装Mesa,因为travis图像非常小。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句