增加优化级别g ++ [英] Increasing Optimization Level g++
问题描述
我试图使用cygwin和g ++编译一个相对简单的c ++程序。我可以使用以下命令编译它:
I'm trying to compile a relatively simple c++ program using cygwin and g++. I can compile it using the following command:
g ++ -o main main.cpp -lgmpxx -lgmp
(注意:最后两个反映了gmp库的包含)。
(note: the last two reflect the inclusion of the gmp libraries).
编译的优化级别。我想我可以只是改变这个命令行为:
I'd like to increase the level of optimization that this is compiled with. I thought that I could just change this command line to:
g ++ -o3 main main.cpp -lgmpxx -lgmp
但这完全炸了。我得到两个全屏的错误消息。
but this totally blows up. I get about two full screens of error messages.
如何提高优化?谢谢!
推荐答案
这应该是 -O3
,而不是 -o3
。否则,你要告诉g ++将编译好的可执行文件放入一个名为 3
的文件中,然后喂它 main
,您之前编译的可执行文件,作为输入。它可能试图将其解释为源代码,因此错误。
That should be -O3
, not -o3
. Otherwise you're telling g++ to put the compiled executable into a file named 3
, and you're feeding it main
, your previously-compiled executable, as input. It's probably trying to interpret that as source code, hence the errors.
这篇关于增加优化级别g ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!