forked from JetBrains/kotlin-web-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(docs.topics.native.platformLibs): add notes
- Loading branch information
alfredo-toledano
committed
Nov 30, 2024
1 parent
6c253fd
commit 6e71902
Showing
1 changed file
with
28 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,42 @@ | ||
[//]: # (title: Platform libraries) | ||
|
||
To provide access to user's native operating system services, | ||
Kotlin/Native distribution includes a set of prebuilt libraries specific to | ||
each target. We call them **Platform Libraries**. | ||
* Kotlin/Native | ||
* **Platform Libraries** | ||
* == prebuilt libraries | ||
* specific / EACH target | ||
* -- provide access to -- user's native OS services | ||
|
||
### POSIX bindings | ||
|
||
For all Unix- or Windows-based targets (including Android and | ||
iOS targets) we provide the POSIX platform lib. It contains bindings | ||
to platform's implementation of the [POSIX standard](https://en.wikipedia.org/wiki/POSIX). | ||
* POSIX platform lib | ||
* uses | ||
* 👀| ALL Unix- or Windows-based targets (ALSO included Android & iOS)👀 | ||
* ❌NOT available | [WebAssembly](https://en.wikipedia.org/wiki/WebAssembly)❌ | ||
* == bindings -- to -- platform's implementation of the [POSIX standard](https://en.wikipedia.org/wiki/POSIX) | ||
* how to use it? | ||
|
||
To use the library, just import it: | ||
```kotlin | ||
import platform.posix.* | ||
``` | ||
|
||
```kotlin | ||
import platform.posix.* | ||
``` | ||
|
||
The only target for which it is not available is [WebAssembly](https://en.wikipedia.org/wiki/WebAssembly). | ||
|
||
Note that the content of `platform.posix` is NOT identical on | ||
different platforms, in the same way as different POSIX implementations | ||
are a little different. | ||
* `platform.posix`'s content != / platforms | ||
* Reason: 🧠== differences / POSIX implementations 🧠 | ||
### Popular native libraries | ||
There are many more platform libraries available for host and | ||
cross-compilation targets. Kotlin/Native distribution provides access to | ||
OpenGL, zlib and other popular native libraries on | ||
applicable platforms. | ||
|
||
On Apple platforms, `objc` library is provided for interoperability with [Objective-C](https://en.wikipedia.org/wiki/Objective-C). | ||
|
||
Inspect the contents of `dist/klib/platform/$target` of the distribution for the details. | ||
* Kotlin/Native | ||
* provides access to | ||
* OpenGL, | ||
* zlib | ||
* others | ||
* _Example:_ | Apple platforms, `objc` library -- is provided for -- interoperability with [Objective-C](https://en.wikipedia.org/wiki/Objective-C) | ||
* see the contents of `dist/klib/platform/$target` | ||
## Availability by default | ||
The packages from platform libraries are available by default. No | ||
special link flags need to be specified to use them. Kotlin/Native | ||
compiler automatically detects which of the platform libraries have | ||
been accessed and automatically links the needed libraries. | ||
* platform libraries' packages are available by default | ||
* == NO need special link flags to use them | ||
* Reason: 🧠 Kotlin/Native compiler -- automatically detects the -- platform libraries / have been accessed -> links the libraries | ||
|
||
On the other hand, the platform libs in the distribution are merely | ||
just wrappers and bindings to the native libraries. That means the | ||
native libraries themselves (`.so`, `.a`, `.dylib`, `.dll` etc) | ||
should be installed on the machine. | ||
* platform libs | distribution == wrappers & bindings to the native libraries | ||
* == native libraries themselves (`.so`, `.a`, `.dylib`, `.dll` etc) -- should be -- installed | machine |