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