简体   繁体   English

Visual Studio中的C ++编译器标志

[英]c++ compiler flags in visual studio

I'm taking a MOOC course on data structures and algorithm. 我正在上有关数据结构和算法的MOOC课程。 I would like to use c++, and I need to set my compiler options to the following 我想使用c ++,并且需要将编译器选项设置为以下内容

g++ -pipe -O2 -std=c++14 -lm g ++-管道-O2 -std = c ++ 14 -lm

I'm currently using MS Visual Studio 2017 on Windows. 我目前在Windows上使用MS Visual Studio 2017。 Is it even possible? 可能吗 Do I need to do custom build? 我需要进行自定义构建吗? The following is the paragraph taken from the MOOC mentions about Windows users having to use Cygwin, but I have no clue what that means. 以下是摘自MOOC的段落,其中提到Windows用户必须使用Cygwin,但我不知道这意味着什么。 Can anybody shed some light on a feasible way to do this? 有人可以阐明实现此目标的可行方法吗?

Your solution will be compiled as follows. 您的解决方案将如下编译。 We recommend that when testing your solution locally, you use the same compiler flags for compiling. 我们建议在本地测试解决方案时,请使用相同的编译器标志进行编译。 This will increase the chances that your program behaves in the same way on your machine and on the testing machine (note that a buggy program may behave differently when compiled by different compilers, or even by the same compiler with different flags). 这将增加您的程序在计算机和测试计算机上以相同方式运行的机会(请注意,有错误的程序在由不同的编译器甚至由具有不同标志的同一编译器进行编译时可能会有不同的行为)。

C++ (g++ 5.2.1). C ++(g ++ 5.2.1)。 File extensions: .cc, .cpp. 文件扩展名:.cc,.cpp。 Flags 标志

g++ -pipe -O2 -std=c++14 -lm g ++-管道-O2 -std = c ++ 14 -lm

If your C/C++ compiler does not recognize the "-std=c++14" flag, try replacing it with "-std=c++11" or "-std=c++0x" flag or compiling without this flag at all (all starter solutions can be compiled without it). 如果您的C / C ++编译器无法识别“ -std = c ++ 14”标志,请尝试将其替换为“ -std = c ++ 11”或“ -std = c ++ 0x”标志,或者在不使用该标志的情况下进行编译根本没有它就可以编译所有入门解决方案)。 On Linux and MacOS, you probably have the required compiler. 在Linux和MacOS上,您可能具有所需的编译器。 On Windows, you may use your favorite compiler or install an environment such as cygwin. 在Windows上,您可以使用自己喜欢的编译器或安装cygwin之类的环境。

As they said you should choose cygwin ( https://cygwin.com/install.html ). 正如他们所说,您应该选择cygwin( https://cygwin.com/install.html )。
These would be the flags for msvc: /std:c++14 /O2 /Im 这些将是msvc的标志: /std:c++14 /O2 /Im

You can set compiler options for each project in its Property Pages dialog box. 您可以在每个项目的“属性页”对话框中为其设置编译器选项。 In the left pane, select Configuration Properties, C/C++ and then choose the compiler option category. 在左窗格中,选择“配置属性”,“ C / C ++”,然后选择“编译器选项”类别。 For the categories lookup: https://docs.microsoft.com/de-de/cpp/build/reference/compiler-options-listed-by-category 对于类别查找: https : //docs.microsoft.com/de-de/cpp/build/reference/compiler-options-listed-by-category

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM