Closed gabrielgggg closed 3 years ago
You should be able to retrieve the include and link flags with pkg-config:
❯ pkg-config nlopt-f --libs
-L/usr/local/lib -lnlopt-f -lnlopt
❯ pkg-config nlopt-f --cflags
-I/usr/local/include -I/usr/local/include/nlopt-f/GNU-11.1.0
Directories that appear with -L
prefix must be made available at runtime by some means, like setting LD_LIBRARY_PATH
, including them in the rpath with -Wl,-rpath,/usr/local/lib
when linking your application or statically linking against the archive. This is quite a general issue with non-system packages and there is not really a single answer to this.
You could adjust install directory with -DCMAKE_INSTALL_PREFIX=/some/path
, but I would recommend to never install in the system prefix (i.e. /usr
), unless you are creating a system package in a separate chroot.
Excellent! Very very helpful, thank you! On clusters of course I don't have root so I will need to install somewhere in home. I'm starting to think whether it would be easier to just compile your four .f90 files as part of my simple Makefile build, and not use cmake at all. Thank you for all the work!
I looked briefly into it but it seemed a bit opaque (that is, I am too much of a brainlet to "get it"). I want to compile the same code on my machine with ifort, some other time I use the cray compiler on an ARM cluster, some of the code is MPI, some is openmp, some both. I didn't see how fpm chooses performance flags and so on. My project usually has 1-2 modules and 1 program, all Fortran, so not much of a "build".
Hello! Say I'm using a simple Makefile or other very simple "manual" command to compile my code. What are the
-I
and-L
I need? Using-I/usr/local/include/nlopt-f/GNU-9.3.0 -L/usr/local/lib -lnlopt-f -lnlopt -lm
compiles fine, but then when I try to run the resulting executable I get
./test: symbol lookup error: ./test: undefined symbol: nlopt_algorithm_from_string
I can run the executable file if I set LD_LIBRARY_PATH before execution, to include
/usr/local/lib
.I installed with cmake/ninja. Is it possible to configure it easily to install the
.a
and.mod
-s and so on in locations that are by default in theLD_LIBRARY_PATH
and include path, or is it a problem with my system (Ubuntu LTS)?Thank you!