I want to use GNU scientific library in Swift, particularly I want to use routines from gsl_rng.h
. So I basically follow https://github.com/apple/swift-package-manager/blob/master/Documentation/SystemModules.md (I am using Linux, not OS X)
I create the module as
module CGSL [system] {
header "/usr/include/gsl/gsl_rng.h"
link "gsl"
export *
}
However, I can't build my program, since I get lots of messages of the kind undefined reference to 'cblas_dasum'
. And indeed, as the documentation for GSL states
To link against the library you need to specify both the main library and a supporting CBLAS library, which provides standard basic linear algebra subroutines. A suitable CBLAS implementation is provided in the library libgslcblas.a if your system does not provide one. The following example shows how to link an application with the library,
$ gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm
What shall I do to link both -lgsl
and -lgslcblas
?