URL: https://www.overclockers.at/linux/gcc-versions-problem_246274/page_1 - zur Vollversion wechseln!
für eine vorlesung brauche ich einen compiler mit unterstützung für c++11, also gcc >= 4.8. ich habe das red hat developer toolset 2 installiert (benutze centos 6.4) der gcc 4.8.2 enthält, und mit update-alternatives dafür gesorgt dass auch gcc 4.8.2 benutzt wird:
make scheint aber immer noch den alten zu verwenden:Code:[root@localhost bin]# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-447 40 --slave /usr/bin/g++ g++ /usr/bin/g++-447 [root@localhost bin]# update-alternatives --install /usr/bin/gcc gcc /opt/rh/devtoolset-2/root/usr/bin/gcc 40 --slave /usr/bin/g++ g++ /usr/bin/g++-447 gcc gcc-ar gcc-nm gcc-ranlib [root@localhost bin]# update-alternatives --install /usr/bin/gcc gcc /opt/rh/devtoolset-2/root/usr/bin/gcc 60 --slave /usr/bin/g++ g++ /opt/rh/devtoolset-2/root/usr/bin/g++ [root@localhost bin]# gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 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. [root@localhost bin]# g++ --version g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 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.
Code:[root@localhost cgcv]$ make [ 45%] Built target cgcv_zlib [ 90%] Built target cgcv_libpng [ 93%] Building CXX object cv/task2/CMakeFiles/cvtask2.dir/CircularList.cpp.o cc1plus: error: unrecognized command line option "-std=c++11" make[2]: *** [cv/task2/CMakeFiles/cvtask2.dir/CircularList.cpp.o] Error 1 make[1]: *** [cv/task2/CMakeFiles/cvtask2.dir/all] Error 2 make: *** [all] Error 2
wie schaut denn das makefile aus?
Code:# CMAKE generated file: DO NOT EDIT! # Generated by "Unix Makefiles" Generator, CMake Version 2.8 # Default target executed when no arguments are given to make. default_target: all .PHONY : default_target #============================================================================= # Special targets provided by cmake. # Disable implicit rules so canonical targets will work. .SUFFIXES: # Remove some rules from gmake that .SUFFIXES does not remove. SUFFIXES = .SUFFIXES: .hpux_make_needs_suffix_list # Suppress display of executed commands. $(VERBOSE).SILENT: # A target that is always out of date. cmake_force: .PHONY : cmake_force #============================================================================= # Set environment variables for the build. # The shell in which to execute make rules. SHELL = /bin/sh # The CMake executable. CMAKE_COMMAND = /usr/bin/cmake # The command to remove a file. RM = /usr/bin/cmake -E remove -f # Escaping for special characters. EQUALS = = # The program to use to edit the cache. CMAKE_EDIT_COMMAND = /usr/bin/ccmake # The top-level source directory on which CMake was run. CMAKE_SOURCE_DIR = "/storage/home/gregor/studium/master/semester 2/computer vision 2/cgcv" # The top-level build directory on which CMake was run. CMAKE_BINARY_DIR = "/storage/home/gregor/studium/master/semester 2/computer vision 2/cgcv" #============================================================================= # Targets provided globally by CMake. # Special rule for the target edit_cache edit_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." /usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : edit_cache # Special rule for the target edit_cache edit_cache/fast: edit_cache .PHONY : edit_cache/fast # Special rule for the target rebuild_cache rebuild_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : rebuild_cache # Special rule for the target rebuild_cache rebuild_cache/fast: rebuild_cache .PHONY : rebuild_cache/fast # The main all target all: cmake_check_build_system $(CMAKE_COMMAND) -E cmake_progress_start "/storage/home/gregor/studium/master/semester 2/computer vision 2/cgcv/CMakeFiles" "/storage/home/gregor/studium/master/semester 2/computer vision 2/cgcv/CMakeFiles/progress.marks" $(MAKE) -f CMakeFiles/Makefile2 all $(CMAKE_COMMAND) -E cmake_progress_start "/storage/home/gregor/studium/master/semester 2/computer vision 2/cgcv/CMakeFiles" 0 .PHONY : all # The main clean target clean: $(MAKE) -f CMakeFiles/Makefile2 clean .PHONY : clean # The main clean target clean/fast: clean .PHONY : clean/fast # Prepare targets for installation. preinstall: all $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall # Prepare targets for installation. preinstall/fast: $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall/fast # clear depends depend: $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 .PHONY : depend #============================================================================= # Target rules for targets named clean-all # Build rule for target. clean-all: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 clean-all .PHONY : clean-all # fast build rule for target. clean-all/fast: $(MAKE) -f CMakeFiles/clean-all.dir/build.make CMakeFiles/clean-all.dir/build .PHONY : clean-all/fast #============================================================================= # Target rules for targets named cgcv_zlib # Build rule for target. cgcv_zlib: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 cgcv_zlib .PHONY : cgcv_zlib # fast build rule for target. cgcv_zlib/fast: $(MAKE) -f cgcvcommon/zlib/CMakeFiles/cgcv_zlib.dir/build.make cgcvcommon/zlib/CMakeFiles/cgcv_zlib.dir/build .PHONY : cgcv_zlib/fast #============================================================================= # Target rules for targets named cgcv_libpng # Build rule for target. cgcv_libpng: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 cgcv_libpng .PHONY : cgcv_libpng # fast build rule for target. cgcv_libpng/fast: $(MAKE) -f cgcvcommon/lpng/CMakeFiles/cgcv_libpng.dir/build.make cgcvcommon/lpng/CMakeFiles/cgcv_libpng.dir/build .PHONY : cgcv_libpng/fast #============================================================================= # Target rules for targets named cvtask2 # Build rule for target. cvtask2: cmake_check_build_system $(MAKE) -f CMakeFiles/Makefile2 cvtask2 .PHONY : cvtask2 # fast build rule for target. cvtask2/fast: $(MAKE) -f cv/task2/CMakeFiles/cvtask2.dir/build.make cv/task2/CMakeFiles/cvtask2.dir/build .PHONY : cvtask2/fast # Help Target help: @echo "The following are some of the valid targets for this Makefile:" @echo "... all (the default if no target is provided)" @echo "... clean" @echo "... depend" @echo "... clean-all" @echo "... edit_cache" @echo "... rebuild_cache" @echo "... cgcv_zlib" @echo "... cgcv_libpng" @echo "... cvtask2" .PHONY : help #============================================================================= # Special targets to cleanup operation of make. # Special rule to run CMake to check the build system integrity. # No rule that depends on this can have commands that come from listfiles # because they might be regenerated. cmake_check_build_system: $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 .PHONY : cmake_check_build_system
Bei mir unter Mint wird die GCC Installation als "gcc-4.8" bzw. "g++-4.8" abgelegt und dann via Symlink nochmals als "gcc" und "g++". Installierst du 4.9 oder ähnliches als Alternative, dann wird jener Symlink vermutlich nicht überschrieben.
den symlink habe ich mit update-alternatives gefixed*, das sollte passen.
*die binary war vorher in /usr/bin, jetzt ist dort ein symlink der von update-alternatives gemanaged wird.
Check nochmal den Symlink?
Ich hab vor ein paar Monaten via Update-Alternatives 4.9 installiert und da tat sich von selbst gar nix...?
So genau hab ich das dann aber ehrlich gesagt auch nicht mehr verfolgt, weil ich ein Tool mit mitgeliefertem Make und installiertem 4.9er ohne Probleme compilieren konnte. Vielleicht gibts da irgendeine fancy Make-Magic, mit der man die Version gezielt aufrufen kann? Leider ist mein Wissen was jene Magie angeht sehr rudimentär.
as said, der symlink funktioniert (musste ich nach der installation von update-alternatives selbst anlegen, siehe 1. post):
angeblich soll man ja mit der option CC=/path/to/compiler den compiler angeben können, wird bei mir einfach ignoriertCode:[root@localhost cgcv]$ gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 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.
Sehr interessant...
Probier mal -std=gnu++11 oder -std=c++1y.
/edit
Das schon probiert?
http://stackoverflow.com/questions/...e-c-11-in-cmake
arhgl... in den makefiles steht /usr/bin/c++ drin, das ist natürlich der alte g++...
Kannst nicht sowas machen (hier im Falle von bash):
Code:$ export CXX="/usr/local/bin/g++-4.8.2"
habe ich damals erfolglos versucht.
ich habe das problem einfach mit ubuntu 16.04 in einer vm gelöst, ich brauchs nur für dieses semester.
overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2025