annotation Link
¶
A lib
can be marked with @[Link(lib : String, *, ldflags : String, framework : String, pkg_config : String)]
to declare the library that should be linked when compiling the program.
At least one of the lib, ldflags, framework arguments needs to be specified.
@[Link(ldflags: "-lpcre")]
will pass -lpcre
straight to the linker.
@[Link("pcre")]
will lookup for a shared library.
1. will lookup pcre
using pkg-config
, if not found
2. will pass -lpcre
to the linker.
@[Link("pcre", pkg_config: "libpcre")]
will lookup for a shared library.
1. will lookup libpcre
using pkg-config
, if not found
2. will lookup pcre
using pkg-config
, if not found
3. will pass -lpcre
to the linker.
@[Link(framework: "Cocoa")]
will pass -framework Cocoa
to the linker.
When an -l
option is passed to the linker, it will lookup the libraries in
paths passed with the -L
option. Any paths in CRYSTAL_LIBRARY_PATH
are
added by default. Custom paths can be passed using ldflags
:
@[Link(ldflags: "-Lvendor/bin")]
.