除此之外,我在Dockerfile中有以下内容,它安装了gcc 5.3.1和gcc 6.3.1:
FROM centos:7
RUN yum install deltarpm -y && \
yum install -y \
centos-release-scl \
epel-release && \
yum install -y \
devtoolset-4-gcc*-5.3.1 \
devtoolset-6-gcc*-6.3.1 \
glibc-*-2.17
当我执行./configure
,make
或类似时,定义使用哪个GCC版本的正确方法是什么?
当我刚安装了一个devtoolset / GCC版本时,我通过在执行PATH
或{{1}之前设置CC
,CXX
,./configure
个环境变量来成功构建}}:
make
当安装两个GCC版本时,我现在尝试了这个(结果不成功):
# gcc 6.3.1
ENV PATH="/opt/rh/devtoolset-6/root/usr/bin:${PATH}"
ENV CC=/opt/rh/devtoolset-6/root/usr/bin/gcc
ENV CXX=/opt/rh/devtoolset-6/root/usr/bin/g++
RUN \
cd app1 && \
./configure && \
gmake && \
gmake install
(部分)错误(来自建筑物Qt4):
ENV original_path="${PATH}"
# gcc 6.3.1
ENV PATH="/opt/rh/devtoolset-6/root/usr/bin:${original_path}"
ENV CC=/opt/rh/devtoolset-6/root/usr/bin/gcc
ENV CXX=/opt/rh/devtoolset-6/root/usr/bin/g++
RUN \
cd app1 && \
./configure && \
gmake && \
gmake install
# gcc 5.3.1
ENV PATH="/opt/rh/devtoolset-4/root/usr/bin:${original_path}"
ENV CC=/opt/rh/devtoolset-4/root/usr/bin/gcc
ENV CXX=/opt/rh/devtoolset-4/root/usr/bin/g++
RUN \
cd app2 && \
./configure && \
gmake && \
gmake install
我也试过了,但这仍然无效:
/opt/rh/devtoolset-4/root/usr/bin/g++ -c -pipe -O2 -I/usr/include/freetype2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_SHARED -DQT_BUILD_OPENGL_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/linux-g++ -I. -I../../include/QtCore -I../../include/QtGui -I../../include -I../../include/QtOpenGL -I.rcc/release-shared -I/usr/include/freetype2
-I../3rdparty/harfbuzz/src -I/usr/X11R6/include -I/usr/X11R6/include -I.moc/release-shared -o .obj/release-shared/qgl2pexvertexarray.o gl2paintengineex/qgl2pexvertexarray.cpp
/opt/rh/devtoolset-4/root/usr/bin/g++ -c -pipe -O2 -I/usr/include/freetype2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_SHARED -DQT_BUILD_OPENGL_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/linux-g++ -I. -I../../include/QtCore -I../../include/QtGui -I../../include -I../../include/QtOpenGL -I.rcc/release-shared -I/usr/include/freetype2
-I../3rdparty/harfbuzz/src -I/usr/X11R6/include -I/usr/X11R6/include -I.moc/release-shared -o .obj/release-shared/qpaintengineex_opengl2.o gl2paintengineex/qpaintengineex_opengl2.cpp
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
gmake[1]: *** [.obj/release-shared/qglgradientcache.o] Error 4
gmake[1]: *** Waiting for unfinished jobs....
gmake[1]: *** [.obj/release-shared/qglengineshadermanager.o] Error 4
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
gmake[1]: *** [.obj/release-shared/qpaintengineex_opengl2.o] Error 4
gmake[1]: Leaving directory `/workdir/qt/src/opengl'
gmake: *** [sub-opengl-make_default-ordered] Error 2
这会在某些构建过程中产生看似随机的错误,这些错误在将多个devtools / gcc安装引入混合之前并未出现。
据我所知,一个人应该可以在同一个系统上安装多个gcc:
https://gcc.gnu.org/faq.html#multiple
- 那我在这里做错了什么?
答案 0 :(得分:0)
证明这可行:
FROM centos:7.3.1611
RUN yum install deltarpm -y && \
yum install -y \
centos-release-scl \
epel-release && \
yum install -y \
# gcc 5.3.1 (via Devtools which is equivalent of RedHat DTS)
devtoolset-4-gcc*-5.3.1 \
make \
# gcc 6.3.1 (via Devtools which is equivalent of RedHat DTS)
devtoolset-6-gcc*-6.3.1 \
devtoolset-6-make* \
# glibc 2.17
glibc-*-2.17
RUN \
cd app1 && \
# gcc 6.3.1
scl enable devtoolset-6 './configure' && \
scl enable devtoolset-6 'gmake' && \
scl enable devtoolset-6 'gmake install'
RUN \
cd app2 && \
# gcc 5.3.1
scl enable devtoolset-4 './configure' && \
scl enable devtoolset-4 'gmake' && \
scl enable devtoolset-4 'gmake install'