# Fpm link issue in conda environment

**URL:** <https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491>\
**Category:** fpm\
**Created:** [March 26, 2025, 3:06pm UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491 "2025-03-26T15:06:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![icpup](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@icpup](https://fortran-lang.discourse.group/u/icpup)\
**Post date:** [March 26, 2025, 3:06pm UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491/1 "2025-03-26T15:06:19Z")

</div>

I have a program need to link external library and module, so in fpm.toml I have:  
[build]  
link = “mylib”  
external-modules = “mymodule”

and FPM\_LDFLAGS environment variable is defined as absolute path using options “-I” and “-L”. This does work in a regular plain system using self-installed fpm package.

However, once in a conda environment using conda’s fpm package, fpm gives error mymodule can’t be found. The fpm.toml and FPM\_LDFLAGS variable are still the same as before.

Anyone has any idea? Am I missing something?

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [March 26, 2025, 4:06pm UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491/2 "2025-03-26T16:06:21Z")

</div>

what version of `fpm` is available in `conda`? you can check it by running

```auto
federico@MacBookPro amr % fpm --version
Version: 0.11.0, alpha
Program: fpm(1)
Description: A Fortran package manager and build system
Home Page: https://github.com/fortran-lang/fpm
License: MIT
OS Type: macOS

```

---

<div class="post-metadata">

**Author:** ![icpup](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@icpup](https://fortran-lang.discourse.group/u/icpup)\
**Post date:** [March 26, 2025, 5:43pm UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491/3 "2025-03-26T17:43:40Z")

</div>

Version: 0.10.1, alpha  
Program: fpm(1)  
Description: A Fortran package manager and build system  
Home Page: [GitHub - fortran-lang/fpm: Fortran Package Manager (fpm)](https://github.com/fortran-lang/fpm)  
License: MIT  
OS Type: Linux

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [March 27, 2025, 7:17am UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491/4 "2025-03-27T07:17:50Z")

</div>

what happens if you pass those flags via the `fpm` CLI interface instead?  
I am no Conda user, but is it possible that it creates a new environment, so the `FPM_LDFLAGS` need be set again after the conda environment is initiated?

Another option would be to please share the output of `fpm --verbose`, that should give us more information.

---

<div class="post-metadata">

**Author:** ![icpup](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@icpup](https://fortran-lang.discourse.group/u/icpup)\
**Post date:** [March 27, 2025, 1:42pm UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491/5 "2025-03-27T13:42:25Z")

</div>

It is the same if passing flags on fpm CLI. My fpm.toml file build section is listed below:

```auto
[build]
auto-executables = false
auto-tests = false
auto-examples = false
link = "mylib"
external-modules = "mymodule"

[dependencies]
stdlib = "*"

[[test]]
name = "test_add"
main = "test_add.f90"

```

The libmylib.a and mymodule.mod is in _/home/jing/mylib/build_ directory.  
I have updated my system wide installed fpm version to 0.11.0, now I have the same problem as in conda environment which has the latest version of 0.10.1

Here is the output:

```auto
(fortran) [jing@Lenovo myproject]$ fpm --verbose test --link-flag "-I$HOME/mylib/build/ -L$HOME/mylib/build/"
 <INFO> BUILD_NAME: build/gfortran
 <INFO> COMPILER: gfortran
 <INFO> C COMPILER: gcc
 <INFO> CXX COMPILER: g++
 <INFO> COMPILER OPTIONS: -cpp -Wall -Wextra -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single
 <INFO> C COMPILER OPTIONS:  
 <INFO> CXX COMPILER OPTIONS: 
 <INFO> LINKER OPTIONS: -I/home/jing/mylib/build/ -L/home/jing/mylib/build/
 <INFO> INCLUDE DIRECTORIES: []
 + mkdir -p build/gfortran_7BA72E36968DE660
[0%] test_add.f90
 + gfortran -c test/test_add.f90 -cpp -Wall -Wextra -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single -fimplicit-none -Werror=implicit-interface -ffree-form -J build/gfortran_6E2E351FB09955DB -Ibuild/gfortran_6E2E351FB09955DB -Ibuild/gfortran_1D6428BD3EB87848 -o build/gfortran_6E2E351FB09955DB/myproject/test_test_add.f90.o
test/test_add.f90:6:9:

    6 | use mymodule
      | 1
Fatal Error: Cannot open module file 'mymodule.mod' for reading at (1): No such file or directory
compilation terminated.
[50%] test_add.f90 done.
test/test_add.f90:6:9:

    6 | use mymodule
      | 1
Fatal Error: Cannot open module file 'mymodule.mod' for reading at (1): No such file or directory
compilation terminated.
<ERROR> Compilation failed for object " test_test_add.f90.o "
<ERROR> stopping due to failed compilation
STOP 1

```

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [March 27, 2025, 5:27pm UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491/6 "2025-03-27T17:27:07Z")

</div>

@icpup, from what you are showing, I believe the `-I/home/jing/mylib/build/` should be a build flag rather than a link flag, and it may be the reason why the compiler can’t find the module files.

---

<div class="post-metadata">

**Author:** ![icpup](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@icpup](https://fortran-lang.discourse.group/u/icpup)\
**Post date:** [March 28, 2025, 2:57am UTC](https://fortran-lang.discourse.group/t/fpm-link-issue-in-conda-environment/9491/7 "2025-03-28T02:57:42Z")

</div>

@FedericoPerini, you are right! I changed option “-I” to compiler flag, problem was solved. Thank you.
