gcc on macOS is running from /opt/local instead of /usr/bin - c++

I was trying to upgrade my gcc version using brew and copying the new version file to usr/bin by using:
sudo ln -s /usr/local/Cellar/gcc/9.3.0/bin/c++-9 /usr/bin/c++
sudo ln -s /usr/local/Cellar/gcc/9.3.0/bin/g++-9 /usr/bin/g++
sudo ln -s /usr/local/Cellar/gcc/9.3.0/bin/gcc-9 /usr/bin/gcc
sudo ln -s /usr/local/Cellar/gcc/9.3.0/bin/gcc-9 /usr/bin/cc
then I add the path to .bash_profile as below
PATH="/usr/local/Cellar/gcc/9.3.0/bin:/usr/local/Cellar/gcc/9.3.0/lib:${PATH}"
export PATH
after all these done, I ran gcc -v, there is no change on version and I found the gcc it gave me was from /opt/local instead of usr/bin. Any idea about this situation?
The terminal below is the gcc -v which computer gives me.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin16/5.4.0/lto-wrapper
Target: x86_64-apple-darwin16
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc5/gcc5/work/gcc-5.4.0/configure --prefix=/opt/local --build=x86_64-apple-darwin16 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc5 --includedir=/opt/local/include/gcc5 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-5 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-5 --with-gxx-include-dir=/opt/local/include/gcc5/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc5 5.4.0_0'
Thread model: posix
gcc version 5.4.0 (MacPorts gcc5 5.4.0_0)

Related

boost built project on i386 fails to link

I am using a project named "GenericMod" which internally uses boost library 1.58.0.
Previously the boost 1.58 was compiled on a Red Hat Enterprise Linux Server release 5.8 (Tikanga)
whose gcc -v output was as follows
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-55)
It was compiled using the following command
./b2 install -a --includedir=testbuild/include --libdir=testbuild/lib --layout=system variant=release target-os=linux link=static runtime-link=static address-model=32 cxxflags=-fPIC
Now, when the project "GenericMod" was build, on the same machine, build was successful and there was no error.
But recently the build environment was changed. The project is being built in a new machine now which is Red Hat Enterprise Linux Server release 5.9 (Tikanga)
and its gcc -v output
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)
When the project is built in this machine now, i was getting linker errors (probably as the boost libraries were built on a different environment).
So i built the boost 1.58.0 in this machine again with the same build command.
./b2 install -a --includedir=testbuild/include --libdir=testbuild/lib --layout=system variant=release target-os=linux link=static runtime-link=static address-model=32 cxxflags=-fPIC
Now when the project is built in this machine, my understanding is that there shouldnt be any error and the build should go through link phase.
But the linker error still occurs.
libboost_thread.a(thread.o): In function `boost::thread::physical_concurrency()':
thread.cpp:(.text+0x2084): undefined reference to `std::ctype<char>::_M_widen_init() const'
Can someone please explain why is this happening ? I have been breaking my head past week for this and couldn;t get enough explanation in other places.
Should i include some flag to specify the build for i386?
Thanks in advance

How to install TBB on Windows and get it work with Eclipse

I want to install Intel's Thread Building Blocks on Windows and get it to work with the Eclipse IDE and C++. I've been new to the whole C, build from source, make, cmake, cygwin and other stuff.
What I've tried so far:
Load the TBB packages and source and try to include it in Eclipse
Try to 'make' TBB from source but only got Error 2 from GNUWin32make
Tried many tutorials, tips and much more that I don't remember any more
How can I do this?
Win 10 - 64bit, Eclipse Oxygen 4.7.0, cygwin 2.8.2, Compiler: mingw
As you can see in Release_Notes.txt, a library doesn't have a Cygwin support. However you have several cases:
Use Visual Studio and binary package
Use Linux (if you really need GCC)
Use Mingw without(!) Cygwin (difference). Building library from source code should work perfect in this case.
Port library to cygwin (it's a non-trivial but real solution)
lost the space by copiying here.
where g++
C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev0\mingw64\bin\g++.exe
C:\MinGW\bin\g++.exe
g++ -v
Using built-in specs. COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\
Files/mingw-w64/x86_64-7.1.0-posix-seh-rt_v5-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/7.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32 Configured with:
../../../src/gcc-7.1.0/configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident
-I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS='
-I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident
-L/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/lib -L/c/mingw710/prerequisites/x86_64-zlib-static/lib -L/c/mingw710/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: posix gcc version 7.1.0 (x86_64-posix-seh-rev0, Built by
MinGW-W64 project)

Homebrew gcc can't find omp.h on OS X

I've spent hours trying different solutions but nothing has worked so far.
I've installed gcc via Homebrew, and linked gcc to the Homebrew gcc. gcc -v returns this:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.3.0/libexec/gcc/x86_64-apple-darwin14.5.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin14.5.0
Configured with: ../configure --build=x86_64-apple-darwin14.5.0 --prefix=/usr/local/Cellar/gcc/5.3.0 --libdir=/usr/local/Cellar/gcc/5.3.0/lib/gcc/5 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew gcc 5.3.0 --without-multilib' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 5.3.0 (Homebrew gcc 5.3.0 --without-multilib)
However, when I try to compile I get
This is make_MWA_Tools.sh
using $CFITSIO =
building LFILE & read_mwac utilities
cc -g -O -Wall -D_FILE_OFFSET_BITS=64 -fopenmp -c mwac_utils.c
mwac_utils.c:3:10: fatal error: 'omp.h' file not found
#include <omp.h>
^
1 error generated.
make: *** [mwac_utils.o] Error 1
!!!!!!!!!!!!!!!!!!!!!!
build_lfiles/read_mwac make failed !
I've looked in gcc located under Cellar and found mop.h, but for some reason its not being included. Any help would be greatly appreciated.
Edit: I don't believe this is a duplicate question because I could not find another question that Installed gcc from Homebrew, linked 'gcc' to the homebrew gcc installation, and still couldn't find omp.h

GCC -v returns GCC 4.7.3 even though I unpacked 4.8.1?

so I went to this link Source Forge MinGW to download and install MinGW 4.8.1. (rev 5). I unpack it into C:\MinGW\mingw32. So I open command prompt (win 32 system) and run gcc -v and I get GCC is 4.7.3. This is the full output of gcc -v:
C:\MinGW\mingw32>gcc -v Using built-in specs. COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.7.3/lto-wrapper.exe
Target: i686-pc-cygwin Configured with:
/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.7.3
/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.
7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --lib execdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --d atarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-cygwin --ho st=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix
--without-li bintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enable-ver sion-specific-runtime-libs --enable-bootstrap --disable-__cxa_atexit --with-dwar f2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-langu ages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite --enable-threads= posix --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmat h-support --enable-libssp --enable-libada --enable-libjava --enable-libgcj-subli bs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java/ecj.jar -
-with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-sy stem-zlib : (reconfigured) /cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src
/gcc-4.7.3/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/ src/gcc-4.7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin
--sbindir=/usr/ sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdi r=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-c ygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix -- without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static -- enable-version-specific-runtime-libs --enable-bootstrap
--disable-__cxa_atexit -
-with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --en able-languages=ada,c,c++,fortran,java,lto,objc,obj-c++
--enable-graphite --enabl e-threads=posix --enable-libgomp --disable-libitm --enable-libquadmath --enable- libquadmath-support --enable-libssp --enable-libada --enable-libjava --enable-li bgcj-sublibs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java /ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-system-zlib Thread model: posix gcc version 4.7.3 (GCC)
C:\MinGW\mingw32>
I would like to know why it unpacked an earlier version and how to fix this. Apparently C::B see's it as an earlier build too! It really baffles me O.o
Also, the prompt returns that threads use Posix when it should be Win32, again really rattling my brain here.
If any one can point to some links, or clear any of this up it would be greatly appreciated!
What you unpacked, and what the OS presents when you call the program, need not be the same thing. Did you do a rehash? Confirm that the path is the same? Or is the new version at a later point in the path? You might want to alias the gcc command to the version you want. Type which gcc to see where the OS thinks the "current version" is located - that should help. EDIT I realize the which command may not work in windows (just noticed the C: drive letter) but the main point about paths is still valid.

C++11 not Working with Macports gcc47

I recently installed Macports on my Macbook Pro, and installed the gcc47 port. After adding alias g++="g++-mp-4.7" to my .profile and ensuring that I was using g++-4.7, I attempted to build one of my projects that makes use of C++11. However, I receive this error:
cc1plus: error: unrecognized command line option "-std=c++11"
I find this strange, since Macports built gcc with support for C++, so I would expect that C++11 should work without any problems. I have pasted the output from g++ -v below. Do you have any ideas as to why g++-mp-4.7 is not recognizing -std=c++11 as a valid option?
COLLECT_GCC=g++-mp-4.7
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.7.1/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.7.1/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --enable-stage1-checking --disable-multilib --enable-lto --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.1_2'
Thread model: posix
gcc version 4.7.1 (MacPorts gcc47 4.7.1_2)
For future reference, if you install gcc_select you can do:
sudo port select gcc mp-gcc47
hash gcc
This should setup your Macports installed gcc; if you need to reset to Xcode's default, just rerun it with 'none'
EDIT: and Xcode 4.4.x comes with a decent build of Clang; if you install it and then from Preferences->Downloads: Command Line Tools click "Install"
Run clang as:
clang++ -std=c++11 -stdlib=libc++ ...
Note that if mp-gcc47 is not installed, you'll need to do this first:
sudo port install mp-gcc47
To get a full list of available gcc ports:
sudo port list | grep gcc | less
My problem was that since GNU Make executes commands in a different shell, alias g++="g++-mp-4.7" will have no effect on the commands executed by make.