Help me out please
I am facing issues in using stdlib on my local(ubuntu 20.04).
I followed the steps given in the readme file.
I have cloned the repo.
Then I created CMake files.
I have also added the path to this folder in my .bashrc file (The very last line of the image given below)
I don’t know how to import them into my project now can you please help me here.
thanks for testing out stdlib. I guess our build instructions could be streamlined further.
Anyways, the procedure which worked for me on WSL was:
- Clone, build, and install stdlib
git clone https://github.com/fortran-lang/stdlib
cmake -B build -DCMAKE_MAXIMUM_RANK=4 -DCMAKE_INSTALL_PREFIX=$HOME/.local
cmake --build build
cmake --install build
- Export the prefix path
- Create a test program calling stdlib and the CMake file
ipribec@thinkpad:/mnt/d/demo/my_code$ cat hello_stdlib.f90
use stdlib_linalg, only: diag
real :: A(3,3), d(3)
A = reshape([1.,2.,3.,4.,5.,6.,7.,8.,9.],[3,3])
d = diag(A)
ipribec@thinkpad:/mnt/d/demo/my_code$ cat CMakeLists.txt
- Build and run your program
ipribec@thinkpad:/mnt/d/demo/my_code$ mkdir build
ipribec@thinkpad:/mnt/d/demo/my_code$ cd build
ipribec@thinkpad:/mnt/d/demo/my_code/build$ cmake ..
-- The Fortran compiler identification is GNU 9.3.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/bin/f95 - skipped
-- Checking whether /usr/bin/f95 supports Fortran 90
-- Checking whether /usr/bin/f95 supports Fortran 90 - yes
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/demo/my_code/build
ipribec@thinkpad:/mnt/d/demo/my_code/build$ make hello_stdlib
Scanning dependencies of target hello_stdlib
[ 50%] Building Fortran object CMakeFiles/hello_stdlib.dir/hello_stdlib.f90.o
[100%] Linking Fortran executable hello_stdlib
[100%] Built target hello_stdlib
1.00000000 5.00000000 9.00000000
That was really helpful and it worked for me.
Thank you @ivanpribec
We also provide an example integration that let’s you use
stdlib within a CMake project here:
The advantage of this setup is that you don’t have to install and/or update
stdlib separately, but build it on demand in the dependent project.
Is there any simple
gfortran based compilation example? I’m trying to avoid any build systems for some small experiments. Pure makefile would do.
Is there also any examples on how to use conda-based fortran-stdlib installation using simple gfortran?