Which compiler options to use with gfortran? [closed] - fortran

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am using Fortran 90 with the gfortran compiler. It's my first experience with a compiled language. Why not just use all of the compiler options when compiling? Would it slow down running the executable? Which compiler options do you recommend? Also, how does gfortran compare to other compilers for Fortran 90? What is important to know about it?

For developing and debugging: -Og -g -Wall -pedantic -fcheck=all
For maximum performance once you have a functioning program, benchmark and test, but as a starting point look in the manual what -O2, -O3, -Ofast, -ffast-math, -funroll-loops, -march=native do. Be particularly careful wrt -Ofast and -ffast-math.

Related

How to get compiler warnings JUCE - Ubuntu [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I was recently dealing with an error that should have easily been realized with a simple compiler warning.
Does anyone know how to get compiler warnings to show up when compiling JUCE projects with make on Ubuntu?
I attempted:
make -Wall from the gcc/gnu Warning Options docs -> no change
make V=1 as commented in the makefile -> it was verbose, but didn't show the warnings
Editing the live build settings in the Projucer -> live build doesn't work on Ubuntu
Edit: Answered by OMGtechy
To add compiler warnings to the build: edit the Linux Makefile settings in the Exporter tab of the Projucer File Manager (See the picture in his answer). However, I didn't see any "uninitialized variable" warnings until I also ran with the optimization flag -O2. Apparently gcc is bad with that warning.
You want to add -Wallto your exporter compiler flags, possibly with -Werror too. Just adding them to the live build flags will only affect the Projucer's live build feature.

C++ compiler on MacOS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
How can I install the C++ compiler on Mac? I need compiler like MinGW on Windows or G++ on Ubuntu, not Clang, that's important.
It is a simple three-step process:
Install Xcode as described here.
Having a C and C++ compiler, now compile the preconditions for the installation of gcc.
Compile and install gcc according to the instructions for gcc. It is a while since I last compiled gcc with clang: you may need to first compile an older release of gcc and use that to compile the actual version of gcc you want.

How do I compile a c++ file on mac? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
The code I have tried porting from windows to compile c++ on a mac does not work.
g++ -W -Wall -pedantic filename.cpp
Try using the following:
g++ -o filename filename.cpp
You could also use XCode.
But ofc, not all the cpp files from Windows could be directly ported on mac: it depends on their content.
You should consider also something like this:
http://mac.sillydog.org/dev/visual_studio.php
Best

Changing gcc/g++ version causes segfault [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
It seems that changing the version of gcc I use from gcc 4.7.3 to gcc 4.9.2 causes a segfault for my project (after a clean build and run).
In an unfortunate turn of events gdb is broken on the server I am
getting this error on and can't use it for now. Any known changes in gcc itself that could cause this? I suspect the issue is potentially caused by a double free.
You should try to use valgrind.
Valgrind is a debugging tool only requiring for your code to be compiled with the -g flag. It's the best way to spot segmentation fault over a program, or any memory leak.
Think about using valgrind options while debugging (it's at the bottom of the valgrind report) something like leak-checkfull (I'm not able to run valgrind right now so I can't tell you exactly what it is).
But whenever I compile my code, I use valgrind with it to check every possible failure. Consider even putting VG in your Makefile rules for more simplicity.

What do these common C++ compiler flags do? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm a starter in C++. I'm still confused about the flags in my makefile.
-c. -o. -Wall. -g. -std=c++0x.
Can any one tell me what all these common flags do?
Only the last flag (compiler command option) is very compiler-specific. The first three or four have been de facto standard since, well, the early or mid 1980s, I think. Of course there’s no guarantee that any particular compiler will understand them, but they’re not uncommon.
Note: while Visual C++ accepts the - flag prefix notation, it is usually used with / as flag prefix, since that’s the common convention in Windows.
-c
Compile only, don't link.
-o
Specifies an output file, e.g. executable. Unfortunately deprecated
for Visual C++ compiler. With Visual C++ use e.g. /Fe.
-Wall
With g++ all practical warnings. With Visual C++ all warnings including all sillywarnings, and that's a bunch!
-g
Generate debug information. Supported by many compilers but not Visual C++.
Then,
-std=c++0x
is a g++ compiler-specific option that specifies sort of C++11 standard. As I recall the difference from -std=c++11, for newer compiler versions that accept both, is that the former still permits some g++-specific language extensions.
Those are not "c++ flags", those are flags for a compiler, presumably it's g++ from the gcc suite.
All those flags are documented on both the online and the offline docs, the offline docs are probably easier to browse for a beginner due to the fact that you can just open the pdf in a viewer and use the search engine to search for a word.
This are the manuals for gcc.