```bash
$ cinterop -def samples/gitchurn/src/nativeInterop/cinterop/libgit2.def -compiler-option -I/usr/local/include -o libgit2
```
we will obtain `libgit2.klib`.
See more details in [INTEROP.md](INTEROP.md)
## klib utility
The **klib** library management utility allows you to inspect and install the libraries.
The following commands are available.
To list library contents:
` argument for specifying a repository different to the default one.
```bash
$ klib -repository
```
## Several examples
First let's create a library.
Place the tiny library source code into `kotlinizer.kt`:
```kotlin
package kotlinizer
val String.kotlinized
get() = "Kotlin $this"
```
```bash
$ kotlinc kotlinizer.kt -p library -o kotlinizer
```
The library has been created in the current directory:
```bash
$ ls kotlinizer.klib
kotlinizer.klib
```
Now let's check out the contents of the library:
```bash
$ klib contents kotlinizer
```
We can install `kotlinizer` to the default repository:
```bash
$ klib install kotlinizer
```
Remove any traces of it from the current directory:
```bash
$ rm kotlinizer.klib
```
Create a very short program and place it into a `use.kt` :
```kotlin
import kotlinizer.*
fun main(args: Array) {
println("Hello, ${"world".kotlinized}!")
}
```
Now compile the program linking with the library we have just created:
```bash
$ kotlinc use.kt -l kotlinizer -o kohello
```
And run the program:
```bash
$ ./kohello.kexe
Hello, Kotlin world!
```
Have fun!
# Advanced topics
## Library search sequence
When given a `-library foo` flag, the compiler searches the `foo` library in the following order:
* Current compilation directory or an absolute path.
* All repositories specified with `-repo` flag.
* Libraries installed in the default repository (For now the default is `~/.konan`, however it could be changed by setting **KONAN_DATA_DIR** environment variable).
* Libraries installed in `$installation/klib` directory.
## The library format
Kotlin/Native libraries are zip files containing a predefined
directory structure, with the following layout:
**foo.klib** when unpacked as **foo/** gives us:
```yaml
- foo/
- targets/
- $platform/
- kotlin/
- Kotlin compiled to LLVM bitcode.
- native/
- Bitcode files of additional native objects.
- $another_platform/
- There can be several platform specific kotlin and native pairs.
- linkdata/
- A set of ProtoBuf files with serialized linkage metadata.
- resources/
- General resources such as images. (Not used yet).
- manifest - A file in *java property* format describing the library.
```
An example layout can be found in `klib/stdlib` directory of your installation.