Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help with usage of this library #4

Closed
Koushikphy opened this issue Jun 19, 2020 · 3 comments
Closed

Need help with usage of this library #4

Koushikphy opened this issue Jun 19, 2020 · 3 comments
Labels
question Further information is requested

Comments

@Koushikphy
Copy link

I have build the library from the source in a local lib directory, now I can't use the library with other codes. My lib folder


├── include
│   ├── h5fortran.mod
│   ├── h5fortran@reader_lt.smod
│   ├── h5fortran@reader.smod
│   ├── h5fortran@read.smod
│   ├── h5fortran.smod
│   ├── h5fortran@writer_lt.smod
│   ├── h5fortran@writer.smod
│   ├── h5fortran@write.smod
│   └── string_utils.mod
├── lib
│   ├── cmake
│   │   └── h5fortran
│   │       ├── h5fortranConfig.cmake
│   │       ├── h5fortranConfigVersion.cmake
│   │       ├── h5fortranTargets.cmake
│   │       └── h5fortranTargets-release.cmake
│   └── libh5fortran.a
└── test_array.f90

and I'm compiling with
gfortran test_array.f90 -I include/ -L lib/ -l:libh5fortran.a
I don't have much knowledge about this, can anyone tell me what I'm doing wrong here?

@scivision
Copy link
Member

It might be a slight typo

gfortran test_array.f90 -I include/ -L lib/ -llibh5fortran.a

@Koushikphy
Copy link
Author

That did not work. But I am little bit confuse from your comment as I knew, to give filename to the linker utility you have to pass the file name as -l:filename where as to link library you have to pass -lnamespec. So, either -l:libh5fortran.a or -lh5fortran would be a valid optioin. Manual page of GNU Linker https://linux.die.net/man/1/ld

-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of files to link. This option may be used   
any number of times. If namespec is of the form :filename, ld will search the library path for a file called   
filename, otherwise it will search the library  path for a file called libnamespec.a.

@scivision
Copy link
Member

Here's how it worked for me:

gfortran -Iinclude test_array.f90 lib/libh5fortran.a

@scivision scivision added the question Further information is requested label Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants