annotation Link

Overview

Alib can be markedwith@[Link(lib : String, *, ldflags : String, static : Bool, framework : String, pkg_config : String, wasm_import_module : String, dll : String)] to declare the library that should be linkedwhen compiling the program.

At least one of thelib,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 lookuppcre usingpkg-config, if not found
  2. will pass-lpcre to the linker.

@[Link("pcre", pkg_config: "libpcre")]will lookup for a shared library.

  1. will lookuplibpcre usingpkg-config, if not found
  2. will lookuppcre usingpkg-config, if not found
  3. will pass-lpcre to the linker.

@[Link(framework: "Cocoa")]will pass-framework Cocoa to the linker.

@[Link(dll: "gc.dll")]will copygc.dll to any built program. The DLL name must use.dll as its file extension and cannot contain any directory separators. The actual DLL is searched amongCRYSTAL_LIBRARY_PATH, the compiler's own directory, andPATH in that order; awarning is printed if the DLL isn't found, although it might still run correctly if the DLLs are available in other DLL search paths on the system.

When an-l option is passed to the linker, itwill lookup the libraries in paths passedwith the-L option. Any paths inCRYSTAL_LIBRARY_PATH are added by default. Custom paths can be passed usingldflags: @[Link(ldflags: "-Lvendor/bin")].

Defined in:

annotations.cr