When I do g++ --versionon my Linux Ubuntu I get g++ (Home-brew GCC 5.5.0_7) 5.5.0. This was installed via brew install gcc.
As the latest version of gcc is 10.2, why has brew not installed this version?
I had also tried
sudo apt update
sudo apt install build-essential
sudo apt install gcc-9and
gcc --version
but it did not change the version. Any advice?
Also, when I try to run an installation script I get the following error
error: command 'home/linuxbrew/.linuxbrew/bin/g++ failed with exit code 1
but
which gcc
gives
/home/linuxbrew/.linuxbrew/bin/g++
so I am not sure what happened.
Related
I compile in Ubuntu 20.04 with gcc 7.5.0 and g++ 7.5.0(supporting cilk plus), but the error says that 'cilk/cilk.h: No such file or directory'the error is shown in the picture
Anybody could help me with the situation? Thanks a lot!
Your compiler still doesn't support cilkplus, just install it via apt-get install:
sudo apt-get install -y libcilkrts5
there you go,
UPDATE: Cilk is not supported with the gcc package on ubuntu 20.04,
to have cilk on ubuntu 20.04 you have to install gcc version < 7 , by the following instruction it's possible to install gcc-6 g++6 on ubuntu 20.04,
sudo vim /etc/apt/sources.list
add "deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe" to file
sudo apt update
sudo apt-get install gcc-6 g++-6 -y
check by gcc -v if you have downgraded correctly the gcc version Then the cilk extension should work.
I'm having trouble installing mysql-python. Created a new virtualenv and when installing mysql-python... here's the error message:
(env)$ pip install mysql-python
Collecting mysql-python
...
clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk build/temp.macosx-10.12-x86_64-2.7/_mysql.o -L/usr /local/Cellar/mysql/5.7.16/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-x86_64-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
Using homebrew, I have installed:
libressl
openssl
openssl#1.1
mysql
Already tried to brew link but brew refuses to do so.
The OS is MacOS Sierra.
Can anyone help? Thanks!
You can set ssl library path explicitly.
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
I tried updating Xcode's CLT, uninstalling mysql, checking mysql_config, etc., but had no luck.
I found that running brew info openssl shows:
...
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
...
Running those two commands, followed by pip install, worked for me (in my case when installing mysqlclient).
Solved it with these steps:
brew uninstall mysql
brew install mysql-connector-c
pip install mysql-python
brew unlink mysql-connector-c
brew install mysql
Found the answer here https://stackoverflow.com/a/25920020/576192
Not sure if this is the right way, but this is how I managed to solve it.
I'm able to fix the error by running:
pip install -r requirements.txt --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"
I was finally able to fix it by
xcode-select --install
I was sure I had already done that... but obviously I hadn't. Definitely worth a shot!
For me on mac, running this command solved the issue
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
Actually we need to set ssl library path to get this issue fixed.
Worked for me by doing this
$ brew uninstall mysql
$ brew install mysql-connector-c
$ brew unlink mysql-connector-c
$ brew install mysql
$ pip install mysql-python
Which is a slightly altered version of the recipe above (note: pip install at the end!)
If you want to install mysql-python, I suggest you to install mysqlclient instead. The authors of these two modules are the same. By far, the authors all turn to keep maintaining mysqlclient. mysqlclient supports both Python 2 and Python 3. And you can use the same codes like mysql-python. Blew is my installation solution for you.
$ brew info openssl
$ brew unlink mysql-connector-c
$ brew install mysql
$ brew link --overwrite mysql-connector-c
$ pip install mysqlclient
If there is an error before pip install mysqlclient. Please fix it according to methane's answer.
And run pip install mysqlclient again.
Or download and install .dmg from the MySQL dev site: https://dev.mysql.com/downloads/file/?id=467834
For those of you who are installing MySQL v5.7 with Brew
Uninstall mysql-connector-c
$ brew uninstall mysql-connector-c
Install specific version, very likely you need to uninstall other installed versions
$ brew install mysql#5.7
You will need to add it to the PATH, since this is 'keg-only' formulae, this is printed after it is installed
$ echo 'export PATH="/usr/local/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
Replace ~/.zshrc with the appropriate file.
Install mysql-connector-c
$ brew install mysql-connector-c
Check it is installed properly
$ which mysql
# /usr/local/opt/mysql#5.7/bin/mysql
$ mysql_config
# Usage: /usr/local/opt/mysql#5.7/bin/mysql_config [OPTIONS]
Compiler: Clang 10.0.0.10001145
Options:
--cflags [-I/usr/local/opt/mysql#5.7/include/mysql ]
--cxxflags [-I/usr/local/opt/mysql#5.7/include/mysql ]
--include [-I/usr/local/opt/mysql#5.7/include/mysql]
--libs [-L/usr/local/opt/mysql#5.7/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/opt/mysql#5.7/lib -lmysqlclient -lssl -lcrypto]
--plugindir [/usr/local/opt/mysql#5.7/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [5.7.24]
--libmysqld-libs [-L/usr/local/opt/mysql#5.7/lib -lmysqld -lssl -lcrypto]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/opt/mysql#5.7/include/mysql]
pkglibdir [/usr/local/opt/mysql#5.7/lib]
plugindir [/usr/local/opt/mysql#5.7/lib/plugin]
Now install mysqlclient
$ pip install mysqlclient
I am using CentOS 7.2
When I use yum groupinstall "Development Tools", gcc version is 4.8.5, like this:
I would like to install gcc 5.3
How to approach this with yum?
Update:
Often people want the most recent version of gcc, and devtoolset is being kept up-to-date, so maybe you want devtoolset-N where N={4,5,6,7...}, check yum for the latest available on your system). Updated the cmds below for N=7.
There is a package for gcc-7.2.1 for devtoolset-7 as an example. First you need to enable the Software Collections, then it's available in devtoolset-7:
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
which gcc
gcc --version
Update: Installing latest version of gcc 9: (gcc 9.3.0) - released March 12, 2020:
Same method can be applied to gcc 10 (gcc 10.1.0) - released May 7, 2020
Download file: gcc-9.3.0.tar.gz or
gcc-10.1.0.tar.gz
Compile and install:
//required libraries: (some may already have been installed)
dnf install libmpc-devel mpfr-devel gmp-devel
//if dnf install libmpc-devel is not working try:
dnf --enablerepo=PowerTools install libmpc-devel
//install zlib
dnf install zlib-devel*
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
make -j 8 <== this may take around an hour or more to finish
(depending on your cpu speed)
make install
Tested under CentOS 7.8.2003 for gcc 9.3 and gcc 10.1
Tested under CentOS 8.1.1911 for gcc 10.1 (may take more time to compile)
Results: gcc/g++ 9.3.0/10.1.0
Installing gcc 7.4 (gcc 7.4.0) - released December 6, 2018:
Download file: https://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.gz
Compile and install:
//required libraries:
yum install libmpc-devel mpfr-devel gmp-devel
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
make -j 8 <== this may take around 50 minutes or less to finish with 8 threads
(depending on your cpu speed)
make install
Result:
Notes:
1. This Stack Overflow answer will help to see how to verify the downloaded source file.
2. Use the option --prefix to install gcc to another directory other than the default one. The toplevel installation directory defaults to /usr/local. Read about gcc installation options
You can use the centos-sclo-rh-testing repo to install GCC v7 without having to compile it forever, also enable V7 by default and let you switch between different versions if required.
sudo yum install -y yum-utils centos-release-scl;
sudo yum -y --enablerepo=centos-sclo-rh-testing install devtoolset-7-gcc;
echo "source /opt/rh/devtoolset-7/enable" | sudo tee -a /etc/profile;
source /opt/rh/devtoolset-7/enable;
gcc --version;
The best approach to use yum and update your devtoolset is to utilize the CentOS SCLo RH Testing repository.
yum install centos-release-scl-rh
yum --enablerepo=centos-sclo-rh-testing install devtoolset-7-gcc devtoolset-7-gcc-c++
Many additional packages are also available, to see them all
yum --enablerepo=centos-sclo-rh-testing list devtoolset-7*
You can use this method to install any dev tool version, just swap the 7 for your desired version. devtoolset-6-gcc, devtoolset-5-gcc etc.
Command to install GCC and Development Tools on a CentOS / RHEL 7 server
Type the following yum command as root user:
yum group install "Development Tools"
OR
sudo yum group install "Development Tools
If above command failed, try:
yum groupinstall "Development Tools
I am trying to compile some c++11 code on ubuntu 12.04. After invoking my makefile I got
cc1plus: error: unrecognized command line option ‘-std=c++11’
Ubuntu gcc 4.7. Fine, so I ran
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7
Ran it again, and still the same problem. Great.So then I tried changing the symlink of gcc from gcc4.6 to 4.7. After doing this, it then went and complained about not being able to find g++. So I then ran
sudo apt-get update
sudo apt-get install build-essential
Still no luck. When I typed g++, I just got
The program 'g++' can be found in the following packages:
*g++
*pentium_builder
Try: sudo apt-get install <selected package>
So I then tried
sudo apt-get install pentium_builder
Now I get
Unable to exec g++.real: No such file or directory
How I can compile c++11 code?
Last time I tried, the following worked for me for installing and setting g++ 4.8 as default:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
It seemed painless, and I was able to choose which gcc/g++ version to use without manually setting up symlinks. I suspect this would work for gcc 4.7 as well.
Add the following to your Makefile:
PROJECT_CFLAGS = -std=c++0x
I'm about to update default GCC (version 4.6.3) shipped by Ubuntu 12.04 to 4.8.2, though the compilation requires a standalone C++ compiler
admin#ubuntu: /usr/local/gcc_build$ sudo make
ends up with
configure: error: C++ compiler missing or inoperational
make[2]: *** [configure-stage1-libcpp] Error 1
Therefore I turn to the process of g++ installation with a preference to the latest version, which means that I would like to compile from source directly rather than apt-get. But seriously, I can't find the source anyway!(O_o). On the other hand, does the source of GCC also come along with that of g++ in the tar file I downloaded, or not? Thanks.
PS: problem remains unsolved with admin#ubuntu: /usr/local/gcc_build$ /home/admin/gcc-4.8.2/configure --enable-languages=c,c++
Add the ppa by
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
Install g++ and gcc (version 4.8)
sudo apt-get update; sudo apt-get install gcc-4.8 g++-4.8
Run the following commands one by one,
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
That's it you are done!
You can easily compile the sources.
The following commands worked for gcc 4.7. They should be fine for gcc 4.8 as well:
sudo apt-get install libmpfr-dev libgmp3-dev libmpc-dev flex bison
svn checkout svn://gcc.gnu.org/svn/gcc/trunk
cd trunk
./configure --prefix=/opt/gcc-4.8.2/usr/local/gcc-4.8.2 --enable-languages=c,c++
make
make install
The compiler will be placed in the /opt/ directory, so you have to use it from there.
Do you want to compile it yourself ? If not, there is a PPA, described here