Gfortran Linking C Libraries with Conda

gfortran linking c libraries with conda

This answer is a suggested alternative workflow that aims at avoiding the problem rather than an exact diagnosis of the issue in OP.

In my experience, I have found the Conda Forge compiler packages help simplify the creation and use of custom environments for compilation. As an example, here is the YAML definition for the environment I use to build the kallisto software. For your case, I would expect something like

fortran-compiler.yaml

name: fortran-compiler  # name it what you want
channels:
- conda-forge
- defaults
dependencies:
- fortran-compiler
- cxx-compiler
- libpng
- libgd
- jpeg
- libnetcdf
- openlibm
- xorg-libx11
# include the other required libraries

Create the environment with

conda env create -f fortran-compiler.yaml

then run your compilation with this environment activated. Activating the environment should automatically manage where the linker will look so that the libraries in the environment will be found (this is, in part, what the Conda Forge *-compiler packages provide). The idea is to have as many libraries as possible come from the environment itself.

I find this approach keeps the amount of manual locating and including of library paths to a minimum. However, it does require having to track down the libraries in Conda Forge (e.g., search for libx11), which unfortunately is not always a one-to-one mapping from library name to package name. The advantage is that a compilation environment defined in this way can facilitate transferring across platforms - e.g., the example YAML I have for kallisto works on both osx-64 and linux-64 without any changes - because it explicitly defines that Conda will provide the shared libraries.

Perhaps there are simpler ways to do this, but this is at least what I've found works after having multiple bad experiences trying to use the gcc or clang Anaconda packages directly.

Failure to import PyMC (gfortran library not loaded after installing from conda.binstar)

This is far from a complete answer, but the following worked, at least with the gfortran compiler installed from brew install gcc. It might work with a different compiler or even without one at all, so try installing it this way:

conda install -c https://conda.binstar.org/tobeplugged pymc

Also, check the updates in the PyMC developers Github page in issue 556

Unable to compile R packages in Ubuntu Conda environment: x86_64-conda-linux-gnu-c++: not found

If you have R in a Conda environment, I would strongly recommend avoiding installs through utils::install.packages. Instead, install through Conda. Many CRAN packages are available through the Conda Forge channel, usually with an "r-" prepended to the package name. So, try

conda install -n qwe -c conda-forge r-bayesem

conda gfortran on osx failed link issue

Your gfortran is too new for your version of Python. Your Python requires libgfortran version 3, but GCC 7 has libgfortran version 4. You will have to install GCC version 6 or older.

See a similar issue on Linux R v3.4.0-2 unable to find libgfortran.so.3 on Arch



Related Topics



Leave a reply



Submit