Errors trying to build package

So I downloaded the binary and the README just says to make it executable so I did with chmod then I executed it and it gives me a basic list of commands I can enter with it. After that I try and run it with build and I get the error below. My setup is Gfortran 9.3 on Kubuntu 20 and my directory is set up as README, LICENSE, fpm.toml then in a folder called app I have my module with the library in it. It does seem to have created a build folder but I don’t think it worked? I also tested the script I wrote a few dozen times and everything is working as expected for what that’s worth.

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x48de81 in ???
#1  0x48d485 in ???
#2  0x4d961f in ???
#3  0x43635b in __fpm_targets_MOD_resolve_module_dependencies
        at ./src/fpm_targets.f90:362
#4  0x43862d in __fpm_targets_MOD_targets_from_sources
        at ./src/fpm_targets.f90:131
#5  0x409fd5 in __fpm_MOD_cmd_build
        at ./src/fpm.f90:268
#6  0x4029f1 in MAIN__
        at app/main.f90:67
#7  0x40195e in main
        at app/main.f90:10
fish: “./fpm-0.3.0-linux-x86_64 build” terminated by signal SIGSEGV (Address boundary error)

Welcome to the Fortran discourse!
I don’t entirely get what you tried there but it sounds like you want to have a library only and no executable, your project structure looks like this:

README
LICENSE
fpm.toml
app
└── library_m.f90

Did you create this structure with fpm new? The app directory should only contain the main program (source file with program fooend program foo). All module files should go into a directory called src. If your project doesn’t have a program/executable and only consists of module files, you don’t need to have an app directory, so you can simply rename appsrc.

4 Likes

I did not use fpm new to make that, I was just formatting it based off of the wiki. Though now that I see fpm new exists I went with that. So that is all done and ready to go, how does one now take the made library and add that to the FPM?

First of all, you can tell fpm new how the new structure should look like and if you don’t need an executable, the default may not fit your needs. In this case you might want to use either fpm new mylibrary --lib or the same command with an additional --test and/or --example.
fpm new will then create the directory structure for you and create dummy source files which may help to understand the purpose of the different directories. Basically you can take all of your modules and copy them into the src directory. In case you have an executable it has to go into the app directory and if there are test routines for your library these should go into the test directory. If you call fpm build it will compile and link all of your files from src into a library file which will then be useable by other source files, for example the test routines.

4 Likes

I’m guessing you mean, “How can I now use my new library in another fpm project?” fpm fetches the dependencies via git, or you can specify a path to a local folder. Note that you do not need to build a library manually before using it in another project; fpm takes care of that for you.

I’d recommend reading the packaging guide and the manifest reference. Those should answer most of your questions.

1 Like