gfortran linking c libraries with conda

后端 未结 1 1085
失恋的感觉
失恋的感觉 2021-01-26 20:27

I am trying to compile a C++/Fortran program using conda on an Ubuntu 18.04 server where I do not have superuser rights.

I am able to compile correctly the program with t

相关标签:
1条回答
  • 2021-01-26 20:39

    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.

    0 讨论(0)
提交回复
热议问题