I am trying to install cupy 5.0.0. cupy5.0.0 needs gcc version not more than 7. My deafault gcc is gcc-9. I cannot use conda environment. Also i dont have sudo permission to change /usr/bin/gcc to point to gcc-7. Is there any way to pass gcc path to pip command?
You can use CXX, CC and LD environment variables to specify executable names or full paths to C++ and C compilers, and the linker.
Specify the variables only for one command:
CXX=g++-7 CC=gcc-7 LD=g++-7 pip install ...
Alternatively:
export CXX=g++-7
export CC=gcc-7
export LD=g++-7
pip install ...
You can also pass extra compiler and linker options in CXXFLAGS, CFLAGS, LDFLAGS. Preprocessor options (e.g. include directories) go in CPPFLAGS.
Related
when I execute
./configure
...
checking for libxml-2.0... no
configure: error: Library libxml2 not found, install library or build without (using --disable-xml).
I installed libxml2 with brew and checked a lot of articles, but nothing helped so far.
UPDATE
./configure --help
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
libxml2_CFLAGS
C compiler flags for libxml2, overriding pkg-config
libxml2_LIBS
linker flags for libxml2, overriding pkg-config
homebrew installs libxml2 as "keg only" which means it is not symlinked to the normal /usr/local/include and /usr/local/lib directories... which means nothing can find it without help. You can get all the above info by running:
brew info libxml2
If you run:
brew ls libxml2
it will tell you the full paths to all the files in that package.
If you also run:
./configure --help
it should tell you what environment variables you need to set in order to find libxml2 So, armed with these last two pieces of info, you should be able to work out what you need to set and how.
I note there is a pkg-config file listed for libxml2 by homebrew at:
/usr/local/Cellar/libxml2/2.9.10/lib/pkgconfig/libxml-2.0.pc
which is also available via a non-version-specific symlink as:
/usr/local/opt/libxml2/lib/pkgconfig/libxml-2.0.pc
so, if you have installed pkg-config with homebrew, like this:
brew install pkg-config
the solution may be just to add the path for that to your PKG_CONFIG_PATH with:
export PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
and then to rerun your configure script.
Note: It is only after installing pkg-config (via brew) that homebrew will display pkg-config related "caveats" for many affected packages e.g. libffi:
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.
For compilers to find libffi you may need to set:
export LDFLAGS="-L/usr/local/opt/libffi/lib"
For pkg-config to find libffi you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
Unfortunately, however, this appears not to be the case for libxml2 for some reason. (Related homebrew issue: "libxml2 install path".)
I wanted to install updated version of gcc on a server where I do not have root access. I tried
conda install -c creditx gcc-7
which was not working. Then I found
conda install -c anaconda gcc_linux-64
in fact installs gccv7.3. But after the successful installation, the conda environment still uses the system gcc at
/usr/bin/gcc
Please help me so that I can use the gcc v7.3 that I just installed.
As explained here: https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html
1) All of the executables in a compiler package are "prefixed." Instead of gcc, the executable name of the compiler you use will be something like x86_64-conda_cos6-linux-gnu-gcc
2) Many build tools such as make and CMake search by default for a compiler named simply gcc, so we set environment variables to point these tools to the correct compiler.
So if you run:
conda create -n cc_env gcc_linux-64
conda activate cc_env
ls $CONDA_PREFIX/bin
You will see a bunch of compiler tools with the prefixed name:
c89 x86_64-conda_cos6-linux-gnu-ct-ng.config x86_64-conda_cos6-linux-gnu-gcov-dump x86_64-conda_cos6-linux-gnu-objdump
c99 x86_64-conda_cos6-linux-gnu-dwp x86_64-conda_cos6-linux-gnu-gcov-tool x86_64-conda_cos6-linux-gnu-ranlib
x86_64-conda_cos6-linux-gnu-addr2line x86_64-conda_cos6-linux-gnu-elfedit x86_64-conda_cos6-linux-gnu-gprof x86_64-conda_cos6-linux-gnu-readelf
x86_64-conda_cos6-linux-gnu-ar x86_64-conda_cos6-linux-gnu-gcc x86_64-conda_cos6-linux-gnu-ld x86_64-conda_cos6-linux-gnu-size
x86_64-conda_cos6-linux-gnu-as x86_64-conda_cos6-linux-gnu-gcc-ar x86_64-conda_cos6-linux-gnu-ld.bfd x86_64-conda_cos6-linux-gnu-strings
x86_64-conda_cos6-linux-gnu-cc x86_64-conda_cos6-linux-gnu-gcc-nm x86_64-conda_cos6-linux-gnu-ld.gold x86_64-conda_cos6-linux-gnu-strip
x86_64-conda_cos6-linux-gnu-c++filt x86_64-conda_cos6-linux-gnu-gcc-ranlib x86_64-conda_cos6-linux-gnu-nm
x86_64-conda_cos6-linux-gnu-cpp x86_64-conda_cos6-linux-gnu-gcov x86_64-conda_cos6-linux-gnu-objcopy
This is ok because environment variables like CC and CPP are pointing to the compiler to use, and commands like make know to use these variable:
$ echo $CC
/home/builder/anaconda3/envs/cc_env/bin/x86_64-conda_cos6-linux-gnu-cc
$ echo $CPP
/home/builder/anaconda3/envs/cc_env/bin/x86_64-conda_cos6-linux-gnu-cpp
For more info on what environment variables make is aware of see: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
when I compile my script with only
#include <mpi.h>
it tells me that there is no such file or directory.
But when i include the path to mpi.h as
#include "/usr/include/mpi/mpi.h"
(the path is correct) it returns:
In file included from /usr/include/mpi/mpi.h:2087:0,
from lbm.cc:7:
/usr/include/mpi/openmpi/ompi/mpi/cxx/mpicxx.h:35:17: fatal error: mpi.h: No such file or directory
#include "mpi.h"
^
compilation terminated.
Anyone know how to fix this?
The problem is almost certainly that you're not using the MPI compiler wrappers. Whenever you're compiling an MPI program, you should use the MPI wrappers:
C - mpicc
C++ - mpiCC, mpicxx, mpic++
FORTRAN - mpifort, mpif77, mpif90
These wrappers do all of the dirty work for you of making sure that all of the appropriate compiler flags, libraries, include directories, library directories, etc. are included when you compile your program.
On my system, I was just missing the Linux package.
sudo apt install libopenmpi-dev
pip install mpi4py
(example of something that uses it that is a good instant test to see if it succeeded)
Succeded.
You can execute:
$ mpicc -showme
result :
gcc -I/Users/<USER_NAME>/openmpi-2.0.1/include -L/Users/<USER_NAME>/openmpi-2.0.1/lib -lmp
This command shows you the necessary libraries to compile mpicc
Example:
$ mpicc -g -I/Users/<USER_NAME>/openmpi-2.0.1/include -o [nameExec] [objetcs.o...] [program.c] -lm
$ mpicc -g -I/Users/<USER_NAME>/openmpi-2.0.1/include -o example file_object.o my_program.c otherlib.o -lm
this command generates executable with your program in example, you can execute :
$ ./example
On my system Ubuntu 16.04. I installed :
sudo apt install libopenmpi-dev
after I used mpiCC to compile and it works
As suggested above the inclusion of
/usr/lib/openmpi/include
in the include path takes care of this (in my case)
Debian appears to include the following:
mpiCC.openmpi
mpic++.openmpi
mpicc.openmpi
mpicxx.openmpi
mpif77.openmpi
mpif90.openmpi
I'll test symlinks of each for mpic, etc., and see if that helps the likes of HDF5-openmpi enabled find mpi.h.
Take that back Debian includes symlinks via their alternatives system and it still cannot find the proper paths between HDF5 openmpi packages and mpi.h referenced in the H5public.h header.
On Ubuntu 18.04 I had to install:
sudo apt install lam4-dev
On Fedora:
dnf install openmpi-devel
On Mac 12.2, I installed with brew install openmpi. The header file is under /opt/homebrew/Cellar/open-mpi/x.x.x/include.
once you have mpi installed:
$ sudo apt install mpich
see where the library is installed, each case is different:
$ mpicc -show
in my case: (Ubuntu 20.0)
and add...
#include </usr/lib/x86_64-linux-gnu/openmpi/include/openmpi>
:-)
I am trying to build GraphChi on OS X Yosemite but get the following error:
fatal error: 'omp.h' file not found
From this question - How to include omp.h in OS X? - I learned that Yosemite uses Clang instead of gcc, which does not include omp.h.
$ which gcc
/usr/bin/gcc
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
Next, I installed gcc via Homebrew
$ brew info gcc
gcc: stable 4.9.2 (bottled)
http://gcc.gnu.org
/usr/local/Cellar/gcc/4.9.2_1 (1092 files, 177M)
Built from source with: --without-multilib
and updated $PATH to include the path to the new gcc version
$ echo $PATH
/usr/local/Cellar/gcc/4.9.2_1:usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
however, gcc -v and which gcc still point to the old version, and building GraphChi still doesn't work due to the missing omp.h file
Does anyone know what else I need to do?
Update
locate omp.h returned:
/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/lib/gcc/i686-apple-darwin11/4.2.1/include/omp.h
/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include/omp.h
/usr/local/Cellar/gfortran/4.8.2/gfortran/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include/omp.h
my ~/.profile:
export PATH=/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include:/usr/local/Cellar/gcc/4.9.2_1/bin:usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH
I solved this with installing gcc with homebrew:
brew install gcc --without-multilib
and then building the source code with
CC=gcc-5 CXX=g++-5 cmake ..
CC=gcc-5 CXX=g++-5 make -j7
Once you have installed gcc-4.9 with homebrew, it will automatically be in your path. To use OpenMP, you just need to make sure you are using the newly installed gcc-4.9, and it will be able to find omp.h.
In the case of GraphChi, you will have to go change line 3 of the Makefile to be gcc-4.9. From there, running make should just work. They describe this in their README, but at least the version they describe is out of date https://github.com/GraphChi/graphchi-cpp#problems-compiling-on-mac.
clang does not support OpenMP yet. Also gcc by default links to Apple's LLVM clang compiler (not the GCC installed from brew).
Instead gcc-4.9 would link to GCC. I think if -fopenmp is specified omp.h is included automatically.
It is possible to manually build a version of clang with OpenMP support, see http://clang-omp.github.io
You shouldn't add the include path to PATH; instead, specify it as CFLAGS, including the -I option. You can export the CFLAGS variable, or set it on the fly.
Depending on how you compile things, you could do
CFLAGS=-I/usr/local/Cellar/gcc/4.9.2_1/lib/gcc/4.9/gcc/x86_64-apple-darwin14.1.0/4.9.2/include/omp.h gcc <whatever>
Of course, in this case you can specify it directly on the gcc command (as -I/usr/local/....), but the CFLAGS variable also works with configure (as configure often won't have an option to specify where it should look for specific include files); probably with make, or even for those installing a Python package: CFLAGS=-I... pip install <some-package>.
Other flags to consider are
CXXFLAGS: C++ specific pre-processor flags
LDFLAGS: linker specific flags (e.g. LDFLAGS=-L/some/path/... for linking with dynamic libraries).
CC: specify the C compiler to use. This is an easy way to avoid the built-in gcc alias for clang on OS X. Just use CC=/usr/local/bin/gcc-4 make or similar.
CXX: specify the C++ compiler to use.
I need to install a package (ROOT) from source on OSX using GCC 4.7.3 as a compiler. Default compiler on OSX is clang, so I look to configure command options to change it. I see that I can change it:
with compiler options, prefix with --with-, overrides default value
cc alternative C compiler and options to be used
cxx alternative C++ compiler and options to be used
But when I run:
./configure --with-cxx=g++ --with-cc=gcc
I see:
Checking for C compiler ... gcc
Checking for C++ compiler ... g++
Checking for linker (LD) ... clang++
So it trying to compile with gcc and link with clang, this obviously leads to failure. But I can't find an option in configure how to change linker used by make.
Is there a default options of configure to change linker? Something like --with-cxxlinker.
If not - how can I find and change the linker used by specific package?
The recommended way of building ROOT from source is to use git and obtain the most recent production version available. As of today that is version 5.34.19.
Open Terminal.app (then use each of the commands in succession):
cd ~/desktop && mkdir root
git clone http://root.cern.ch/git/root.git && cd root
./configure
make
make install
The nice thing about using git is that it contains a complete source tree for all systems (72 MB). You shouldn't need to use any special ./configure commands (unless you want to use add-on components).
You could also install the Mac Ports version by using the command:
sudo port install root