2010-06-07 5 views
70

Windows 7 (64 비트)에서 최근에 1.3.2, Qt 4.6.2 및 GCC 4.4.0 (32 비트 버전)을 사용하려고했습니다. 실험 C의 몇 가지 + +0 확장을 사용하여 응용 프로그램을 컴파일하고 다음의 치명적인 오류가 발생했습니다 솔루션에 대한 내 검색에서Qt, QtCreator 및 QMake에서 GCC 컴파일러 스위치 구성

This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.

을, 나는 스레드 qmake and compiler flags? 건너 온과에 다음을 추가 .pro 파일 :

CXXFLAGS += -std=c++0x 

그러나 그것은 차이를 만드는 것처럼 보이지 않았습니다.

그래서 저는 .pro (프로젝트) 파일에 추가 할 필요가있는 태그가있을 것으로 기대합니다. 그러나 Qt, QMake 및 QtCreator에서 GCC 컴파일러 스위치를 사용 해 본 적이 결코 없었습니다. 적절한 부름/주문. 그래서, 내 질문에 어떻게 QtCreator, QMake 및 Qt 사용할 때 GCC 컴파일러 스위치를 설정합니까?

답변

100

manual을 읽는 것으로 귀결됩니다.

MAIN.CPP :

#include <cinttypes> 

int main() { return 0; } 

main.pro :

SOURCES += main.cpp 
QMAKE_CXXFLAGS += -std=c++0x 
+5

이 플래그는 몇 가지 이유로 QtCreator 2.4.1에서 여전히 작동하지 않습니다. – Chan

+0

깃발을 어디에서 사용하고 있습니까? – andand

+1

+1,'QMAKE_CXXFLAGS + = ... '는 빌드 설정 (즉 명령 행)에서 추가 인수로 지정할 수도 있습니다. – MDMoore313

3

당신은

를 사용해야하는 대신 .PRO 파일에 CXXFLAGS을 사용하여, 당신은에로 QMAKE_CXXFLAGS을 사용할 필요가
CONFIG += c++11 

을 사용하면 C++ 11 컴파일러 플래그를 자동으로 활성화 할 수 있습니다.

qt 설치에서 .prf 파일을 찾으십시오. 나는 그들이 윈도우에 어디에 있을지 모르지만, 리눅스 설치시 그들은 /opt/Qt/5.4/gcc_64/mkspecs/features이다.

당신은에 대한 qmake documentation을 읽을 수 있습니다

qmake can be set up with extra configuration features that are specified in feature (.prf) files. These extra features often provide support for custom tools that are used during the build process. To add a feature to the build process, append the feature name (the stem of the feature filename) to the CONFIG variable.

당신은 add your own features을 할 수 있습니다.

다음은 시스템에서 발견 한 것입니다. 정말 날QMAKE_CXXFLAGS에 추가 이다 작동

./android/android_deployment_settings.prf 
./android/android.prf 
./build_pass.prf 
./c++11.prf 
./c++14.prf 
./cmake_functions.prf 
./configure.prf 
./create_cmake.prf 
./ctest_testcase_common.prf 
./ctest_testcase_installed.prf 
./ctest_testcase.prf 
./dbusadaptors.prf 
./dbusinterfaces.prf 
./declarative_debug.prf 
./default_post.prf 
./default_pre.prf 
./designer_defines.prf 
./device_config.prf 
./egl.prf 
./exceptions_off.prf 
./exceptions.prf 
./exclusive_builds_post.prf 
./exclusive_builds.prf 
./gcov.prf 
./include_source_dir.prf 
./incredibuild_xge.prf 
./java.prf 
./lex.prf 
./link_ltcg.prf 
./link_pkgconfig.prf 
./ltcg.prf 
./mac/default_post.prf 
./mac/default_pre.prf 
./mac/objective_c.prf 
./mac/rez.prf 
./mac/sdk.prf 
./moc.prf 
./no_debug_info.prf 
./precompile_header.prf 
./qfeatures.prf 
./qlalr.prf 
./qml1_module.prf 
./qml1_plugin.prf 
./qml_debug.prf 
./qml_module.prf 
./qml_plugin.prf 
./qmltestcase.prf 
./qpa/basicunixfontdatabase.prf 
./qpa/genericunixfontdatabase.prf 
./qt_android_deps.prf 
./qt_app.prf 
./qt_build_config.prf 
./qt_build_paths.prf 
./qt_common.prf 
./qt_config.prf 
./qt_docs.prf 
./qt_docs_targets.prf 
./qt_example_installs.prf 
./qt_functions.prf 
./qt_headersclean.prf 
./qt_helper_lib.prf 
./qt_installs.prf 
./qt_module_headers.prf 
./qt_module.prf 
./qt_module_pris.prf 
./qt_parts.prf 
./qt_plugin.prf 
./qt.prf 
./qt_targets.prf 
./qt_tool.prf 
./resolve_config.prf 
./resolve_target.prf 
./resources.prf 
./silent.prf 
./simd.prf 
./spec_post.prf 
./spec_pre.prf 
./testcase.prf 
./testcase_targets.prf 
./testcocoon.prf 
./testlib_defines.prf 
./uic.prf 
./unix/bsymbolic_functions.prf 
./unix/dylib.prf 
./unix/hide_symbols.prf 
./unix/largefile.prf 
./unix/opengl.prf 
./unix/openvg.prf 
./unix/separate_debug_info.prf 
./unix/thread.prf 
./unix/x11inc.prf 
./unix/x11lib.prf 
./unix/x11.prf 
./unix/x11sm.prf 
./use_c_linker.prf 
./vxworks.prf 
./warn_off.prf 
./warn_on.prf 
./wayland-scanner.prf 
./win32/console.prf 
./win32/default_pre.prf 
./win32/dumpcpp.prf 
./win32/idcidl.prf 
./win32/msvc_mp.prf 
./win32/opengl.prf 
./win32/openvg.prf 
./win32/qt_config.prf 
./win32/qt_dll.prf 
./win32/rtti_off.prf 
./win32/rtti.prf 
./win32/stl_off.prf 
./win32/stl.prf 
./win32/windeployqt.prf 
./win32/windows.prf 
./winrt/console.prf 
./winrt/font_deployment.prf 
./winrt/package_manifest.prf 
./yacc.prf 
1

유일한 방법 : CONFIG + = 이름이 기능을 사용합니다.

CONFIG += c++11-std=c++11을 컴파일 명령에 추가하지 않습니다.

+0

이 질문은 2010 년에 요청되었다는 것을 명심하십시오.'CONFIG + = C++ 11'은 qtcreator 3.X + (2012 년에 다시 릴리스 됨)에 대한 올바른 해결책입니다. – smerlin

관련 문제