installing gfortran in cygwin: gfortran: cyglto_plugin.dll not found - fortran

I'm trying to get the gfortran compiler with cygwin. When attempting to compile a hello world program, I get the following error:
gfortran: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
To install the compiler, I used the cygwin setup and selected
gcc-fortran: GNU compiler collection
libgfortran3: GCC fortran runtime library
I also mistakenly selected the toolchains for mingw, even though I don't have the mingw compiler (as far as I'm aware). g++, which I installed awhile ago, works fine.
What do I need to do to compile/find the library?

It is because of the gcc and gfortran versions are not same, try checking that. If so, do the following
$ apt-cyg remove gcc-fortran
$ apt-cyg install gcc-fortran

Related

Cannot find -lubsan on using -fsanitize=undefined (mingw-w64)

I'm using mingw-w64 (gcc 7.3.0) and when I compile any C++ program using the following command:
g++ file.cpp -fsanitize=undefined
I get the following error:
...mingw32/bin/ld.exe: cannot find -lubsan
I'm able to successfully compile and run my programs if I remove the -fsanitize=undefined flag, though. After some research I found out that this means the library ubsan (Undefined Behavior Sanitizer) is missing, but I couldn't find anything about the library. How do I fix this?
This is well known issue with mingw see for instance this msys github issue. No proper solution known but there are several WAs.
Install WSL, ubuntu over WSL and you will have ubsan inside it
Build GCC under Windows from source enabling sanitizers build. They are present in GCC sources they are just not here in mingw.
Use -fsanitize=undefined -fsanitize-undefined-trap-on-error to just not use libubsan rich logging capabilities but get it trap on undefined instruction.
Hope one of this helps.

Trying to compile a C++ code with Root (Cern) parameters included

I working on trying to compile a code written in C++ and Root on my Mac. The code is from a colleague who works on a Linux laptop. In addition to the different OS's, I have both a different version of gcc and Root than her and I am not sure which difference is causing the code not to compile on my machine.
She has g++ 4.8 and root 5.(something). I have gcc 5.3.0 and root 6.06/02.
She has given to me the a line of code she uses to get her machine to compile the code
gcc -Wall -o executable_name code_name.cc `root-config --cflags --glibs`
But when I write on my machine, Terminal gives me the error
gcc: error: unrecognized command line option ‘-stdlib=libc++’
gcc: error: unrecognized command line option ‘-stdlib=libc++’
I need help generating the correct line to get gcc to compile the code.
The problem here is two-fold: You're on OSX and you are using GCC.
The problem with this is that root-config assumes that since you're on OSX you will be using the OSX-standard Clang compiler which have the -stdlib flag. Since you're not using Clang, but GCC (which doesn't have this flag) you get an error.
You have two possible solutions: Use clang++ instead of g++ to compile and build (requires you to install the compiler if it's not installed already, it comes with Xcode), or to modify the root-config script so it doesn't add -stdlib=libc++. There might be environment variables or flags that the root-config script checks that alter the behavior, but I don't know anything about the script, you have to check it for that.

Can not install gfortran via homebrew

I got this message when i tried to install gfortran.
~$ brew install gfortran
Error: No available formula for gfortran
GNU Fortran is now provided as part of GCC, and can be installed with:
brew install gcc
My question is how to install gfortran with homebrew or port?
or
If now GNU Fortran is a part of GCC How can i compile fortran code using gcc?
I'm not sure may be i've misunderstood something i remember that the last time i still can use gfortran to compile my code but now it doesn't work.
Further information:
when i use command brew list i still see that gfortran is there but can not use it.
Further information (latest):
ok, now i can use gfortran command but another problem come
~$ gfortran-4.9 hello.f
dyld: Library not loaded: /usr/local/lib/libcloog-isl.4.dylib
Referenced from: /usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/f951
Reason: image not found
gfortran-4.9: internal compiler error: Trace/BPT trap: 5 (program f951)
Abort trap: 6
Just do "brew install gcc" per the instructions. The gcc package contains gcc, g++, gfortran etc.

Eclipse /bin/sh: g++: command not found

I had to upgrade my gcc version to utilize the new C++11 standards. After following the instructions at http://ask.xmodulo.com/upgrade-gcc-centos.html . I started getting the error "/bin/sh: g++: command not found" when I try to build my project. How can I fix this? It looks like gcc installed fine by looking at the below output.
gcc --version
gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
G++ appears to be not installed. Find how to install gcc in your OS. After this, you have to make Eclipse find g++. I recommend to you, to install CDT plugins. They have many ready tools for C/C++ programming and it is fully compatible with gcc toolset.

C++11 on Mac with Clang or GCC

I have Xcode 4.5.2 on Moutain Lion, and I have install the lastest "Command Line Tools" but when I tried to compile with g++ or clang++ (and the options -std=c++11 -stdlib=libc++) I get an error.
With g++:
cc1plus: error: unrecognized command line option "-std=c++11"
cc1plus: error: unrecognized command line option "-stdlib=libc++"
With clang++:
clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
It's in a Qt project.
So how can I used the C++11 on my Mac ?
As you found, g++ does not support those command line options.
It sounds like you're using Xcode.
For clang, you should look at the project settings, and make sure that the "Deployment Target" is set to 10.7 (or 10.8)
What the error message is telling you is that libc++ is not available for 10.6 and before.
I installed gcc-4.7 on my Mac to make C++11 work. GCC in its current version is fairly good at supporting C++11, so this should be a fair choice.
The installation can be done by Homebrew and is not that complicated (at least I was able to do it...)
To install Homebrew if you do not already have it:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
Now run
brew doctor
and fix whatever problems come up (there is something written in the hombrew documentation for that). Finally, install current gcc:
brew install gcc
If everything goes well you should be able to access g++-4.7, which allows -std=c++0x.
Try -std=c++0x if c++11 doesn't work. Support for the -std=c++11 option is relatively new in GCC and you might not have a recent enough version.
I'd trust Marshall on the libc++ issue.