Increasing Optimization Level g++

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 17:22:37

问题


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

(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.

How can I increase the optimization here? Thanks!


回答1:


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.




回答2:


Options are case sensitive: the -o option allows you to specify the name of the output file, -O sets the amount of optimisation, so you want:

g++ -O3 -o main main.cpp -lgmpxx -lgmp


来源:https://stackoverflow.com/questions/10021536/increasing-optimization-level-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!