Errors building stdlib

Windows 11 24H2
Intel oneAPI Base Toolkit 2025
Intel HPC Toolkit 2025
VS 2022

I followed the Readme file.

pip install --user fypp cmake ninja
cmake -B build
cmake --build build giving lots of errors.

This is part of the error messages:

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.13.1 Build 20240703_000000
Copyright (C) 1985-2024 Intel Corporation.  All rights reserved.
ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '/Qdiag-disable:10448' to disable this message.
Compiling manifest to resources...
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.13.1 Build 20240703_000000
Copyright (C) 1985-2024 Intel Corporation.  All rights reserved.
ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '/Qdiag-disable:10448' to disable this message.
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.
Linking...
Link: executing 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe'
Microsoft (R) Incremental Linker Version 14.43.34808.0
Copyright (C) Microsoft Corporation.  All rights reserved.
/OUT:D:\Fortran_stdlib\build\example\logger\Debug\example_add_log_unit.exe
/VERSION:0.0
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
/MANIFEST
Copyright (C) Microsoft Corporation.  All rights reserved.
/MANIFESTFILE:example_add_log_unit.dir\Debug\example_add_log_unit.exe.intermediate.manifest
Linking...
"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
/SUBSYSTEM:CONSOLE
/IMPLIB:D:\Fortran_stdlib\build\example\logger\Debug\example_add_log_unit.lib
user32.lib
..\..\src\Debug\fortran_stdlib.lib
/machine:x64
/debug
/INCREMENTAL
example_add_log_unit.dir\Debug\example_add_log_unit.obj
example_add_log_unit.dir\Debug\example_add_log_unit.exe.embed.manifest.res
LINK : fatal error LNK1104: cannot open file '..\..\src\Debug\fortran_stdlib.lib'

Build log written to  "file://D:/Fortran_stdlib/build/example/logger/example_add_log_unit.dir/Debug/BuildLog.htm"
example_add_log_unit - 1 error(s), 0 warning(s)
Link: executing 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe'
Microsoft (R) Incremental Linker Version 14.43.34808.0
Copyright (C) Microsoft Corporation.  All rights reserved.
/OUT:D:\Fortran_stdlib\build\example\string_type\Debug\example_adjustr.exe
/VERSION:0.0
/MANIFEST
/MANIFESTFILE:example_adjustr.dir\Debug\example_adjustr.exe.intermediate.manifest
"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
/SUBSYSTEM:CONSOLE
/IMPLIB:D:\Fortran_stdlib\build\example\string_type\Debug\example_adjustr.lib
user32.lib
..\..\src\Debug\fortran_stdlib.lib
/machine:x64
/debug
/INCREMENTAL
example_adjustr.dir\Debug\example_adjustr.obj
example_adjustr.dir\Debug\example_adjustr.exe.embed.manifest.res
LINK : fatal error LNK1104: cannot open file '..\..\src\Debug\fortran_stdlib.lib'

Build log written to  "file://D:/Fortran_stdlib/build/example/string_type/example_adjustr.dir/Debug/BuildLog.htm"
example_adjustr - 1 error(s), 0 warning(s)
Link: executing 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe'
Microsoft (R) Incremental Linker Version 14.43.34808.0
Copyright (C) Microsoft Corporation.  All rights reserved.
/OUT:D:\Fortran_stdlib\build\example\string_type\Debug\example_adjustl.exe
/VERSION:0.0
/MANIFEST
/MANIFESTFILE:example_adjustl.dir\Debug\example_adjustl.exe.intermediate.manifest
"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
/SUBSYSTEM:CONSOLE
/IMPLIB:D:\Fortran_stdlib\build\example\string_type\Debug\example_adjustl.lib
user32.lib
..\..\src\Debug\fortran_stdlib.lib
/machine:x64
/debug
/INCREMENTAL
example_adjustl.dir\Debug\example_adjustl.obj
example_adjustl.dir\Debug\example_adjustl.exe.embed.manifest.res
LINK : fatal error LNK1104: cannot open file '..\..\src\Debug\fortran_stdlib.lib'

Build log written to  "file://D:/Fortran_stdlib/build/example/string_type/example_adjustl.dir/Debug/BuildLog.htm"
example_adjustl - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 315 failed, 2 up-to-date, 0 skipped ==========
========== Build completed at 11:42 and took 02:27,274 minutes ==========

Roger

Getting stdlib built is an on going struggle. First of all, did you build the fpm branch? If not give that a try. The main branch requires fypp preprocessing, which is an additional layer of complexity.

I think the issue is that you did not specify the generator in your command line.

Could you try:

cmake -B build -G Ninja
cmake --build build

if fypp is installed in the python distribution visible from the user path, then you need not worry about this. I build stdlib from the main branch all the time and it does the fypp pre-preprocessing without me having to manually set two steps as it was already integrated in the CMake scripts.

For fpm you can also use GitHub - fortran-lang/stdlib: Fortran Standard Library to preprocess and build from the main branch.

Thanks!
Seems to work, but now I get several warnings:
f951.exe: Warning: Nonexistent include directory 'src\mod_files' [-Wmissing-include-dirs]
Don’t know if I can ignore that.

The tests passed too except 109 (skipped)

100% tests passed, 0 tests failed out of 315

Label Time Summary:
quadruple_precision    =   0.41 sec*proc (2 tests)

Total Test time (real) =  52.96 sec

The following tests did not run:
        109 - check4 (Skipped)

Roger

Hello,

I tried to compile a hashmap example.
I get the following error:
error #7002: Error in opening the compiled module file. Check INCLUDE paths. [STDLIB_HASHMAPS]
stdlib is in C:\Program Files (x86)\fortran_stdlib
I am a novice in that regard.
I suppose the linker does not find the library files.
Would it be OK to put the mod file into the same directory as the source file.
Update. When I do that I get error #7013: This module file was not generated by any release of this compiler. [STDLIB_HASHMAPS]
Here is the code Copyright Chuckyvt

`program example_hashamp
  use stdlib_hashmaps, only: chaining_hashmap_type
  use stdlib_hashmap_wrappers, only: fnv_1_hasher, set, get
  implicit none

  type(other_type)            :: other
  type(chaining_hashmap_type) :: map

  type steel_profile
    integer :: a
    real :: mm, h, b, tw, tf, r
  end type steel_profile

  type(steel_profile) :: profile
  character(len=32) :: profile_name
  character(len=:), allocatable :: name_to_lookup

  ! Initialize hashmap
  call map%init(fnv_1_hasher)
  
  ! Add code here to read text file, and store data in steel_profile type and profile_name. 
  ! Perhaps looks something like below?
  do i = 1, num_lines  
    read(*,*) profile_name, profile % mm, profile % b
  
    ! Store dervied type with profile name as the lookup key.
    call set(other, profile_name)  ! Hope to remove this step in a future version of stdlib 
    call map%map_entry(trim(profile_name), other)
  enddo

  !  Then to retrieve
  name_to_lookup = 'HEA340'
  call map%get_other_data(name_to_lookup , other)
  
  get(other,data)  ! Hope to remove this step in a future version of stdlib   
  select type (data)   ! Stored as unlimited polymorphic.  Must be wrapped in a select type construct.
    type is (steel_profile)
      print *, name_to_lookup, "A values is ", data % A
  end select
end program
________________________________________
`

Bear with me for a bit and lets try to get you in a more comfortable path:

  1. Please, do yourself a favor and do not work in this directory C:\Program Files (x86), for you as an user it should be like Mordor. Also, white spaces in the path usually lead to issues. So refrain from using this folder for your own development work.

  2. Let’s navigate the fpm way, I promise, it will ease things from here onwards… Open Terminal, it should open in a PowerShell terminal, from here install fpm

winget install FortranLang.fpm
  1. I saw you have a D drive, so let’s work in a safer space, from your PowerShell terminal (assuming that it is currently pointing somewhere in your C drive) :
D:
mkdir fortran_lang
git clone https://github.com/fortran-lang/stdlib.git
cd stdlib
python config/fypp_deployment.py

This will download stdlib and pre-preprocess all the fypp files such that you can build stdlib with fpm, and if you later want to change the defaults it will be possible.

  1. Create your own project to play around, one level up:
cd ..
fpm new my_project
cd my_project

In the fpm.toml, add stdlib as a dependency using your locally downloaded version fpm local dependencies:

[dependencies]
stdlib = { path = "../stdlib" }

You can copy-paste example programs in the app folder of your local project and do fpm run to play around.

You might want to read this thread Fortran stdlib: sufficient for scientific programming? - #22 by hkvzjal

1 Like

Thanks a lot!
Works fine.
The test runs.
However when I try to run the hash program it compiles but the linker gives : undifined reference to ‘WinMain’

src> gfortran -o hash hash.f90
C:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status

Roger

@rmoortgat the issue here, and what you experienced before, is that you are compiling a single file without linking the static library. When you build a library, it is not integrated to the compiling process, it is a binary object that you need to tell the compiler to link against, and as such tell him where it is… That being said, I recommend you using fpm because it will take care of all of that hassle on your behalf.

So within your project, do not build a single file calling the compiler in that manner. Simply call fpm build or fpm run, you can change the compiler that fpm will use, for instance fpm run --compiler ifx will use ifx if it is visible on your path instead of gfortran.

Thanks again!
All running now.

Roger