# A new experimental package for Odin

**URL:** <https://forum.systemcrafters.net/t/a-new-experimental-package-for-odin/1370>\
**Category:** Guix\
**Tags:** programming, guix\
**Created:** [February 2, 2025, 6:19pm UTC](https://forum.systemcrafters.net/t/a-new-experimental-package-for-odin/1370 "2025-02-02T18:19:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![altomcat](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/altomcat/32/583_2.png) [@altomcat](https://forum.systemcrafters.net/u/altomcat)\
**Post date:** [February 2, 2025, 6:19pm UTC](https://forum.systemcrafters.net/t/a-new-experimental-package-for-odin/1370/1 "2025-02-02T18:19:12Z")

</div>

Hello,

I started to build a **Guix** definition package for [ODIN programming language](https://odin-lang.org/). You can find it [here](https://github.com/altomcat/bric-a-brac/blob/master/bric-a-brac/packages/odin.scm#L42).

This package provides two executables:

- `odin`: the compiler
- `demo-odin`: the demo from the examples directory

**Odin** relies on clang for the linker, you´ll need to add the `clang-toolchain` to build an executable.

It’s really a first draft but for me, it’s already enough to start learning and exploring the language.

Third party libraries are available as pre-compiled static libraries for different architectures. For linux platform, most of them need to be compiled. For safety reasons and overall size, those libraries have been removed. If dynamic libraries are available, they will be used by the linker (glfw, sdl2, opengl).  
Execution of compiled application can lead to failure due to a library missing at runtime. Some work around based on the usage of `patchelf` or prepend the execution by using an environment variable like `LD_LIBRARY_PATH` or `LD_PRELOAD` can fix the issue.

Current limitations:

- x86\_64 only
- some third party vendor libraries are not available (_Raylib_, _box2d_, …)
  - _Raylib_ was working but I removed the provided libraries since …
  - Find a way to provide extra packages for ODIN and bind them to an immutable folder called `vendor`.
  - or if feasible use the additional `-collection:shared=path/to/shared/libs` to the compiler.

- some tests leads to segmentation fault (tests/core and tests/benchmark),  
whereas other works: `odin test tests/internal`

To experiment with this package, one can use this basic manifest.scm:

```scheme
(specifications->manifest
 (list "odin"
       "clang-toolchain@18"
       ;; "raylib"
       "glfw@3.4"
       "sdl2"
       "coreutils"
       ;; "patchelf"
       ;; "libtree"
       ;; "strace"
       ))

```

There are more examples to play with available [here](https://github.com/odin-lang/examples).

Examples based on _glfw_, _opengl_ or _sdl2_ should run out of the box.

```shell
guix shell -m manifest.scm -- odin run more-examples/glfw/window
guix shell -m manifest.scm -- odin run more-examples/sdl2/chase_in_space

```

I’m currently building and running this package on this laptop:

```auto
~/projects/odin/src [env]$ odin report
Where to find more information and get into contact when you encounter a bug:

Website: https://odin-lang.org
GitHub: https://github.com/odin-lang/Odin/issues

Useful information to add to a bug report:

Odin: dev-2025-02
OS: Guix System, Linux 5.15.167.4-microsoft-standard-WSL2
CPU: 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
RAM: 3826 MiB
Backend: LLVM 18.1.8

```

Feel free to give me feedback or advices of some sort.  
To be continued and Happy coding, Arnaud.

---

<div class="post-metadata">

**Author:** ![altomcat](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/altomcat/32/583_2.png) [@altomcat](https://forum.systemcrafters.net/u/altomcat)\
**Post date:** [February 4, 2025, 11:16am UTC](https://forum.systemcrafters.net/t/a-new-experimental-package-for-odin/1370/2 "2025-02-04T11:16:44Z")

</div>

I dug a little deeper into the raylib vendor part. Odin seems to have a preference for static libraries:

```auto
~/projects/odin/src [env]$ odin build more-examples/raylib/game_of_life
ld: cannot find -l:/gnu/store/hkjs78119h6kzxyjry2jfrkrhvqwdxch-odin-0.0-dev-2025-01.2aae4cf/vendor/raylib//linux/libraylib.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

```

When you look at the code, it clearly says.  
`RAYLIB_SHARED :: #config(RAYLIB_SHARED, false)`

But you can easily force dynamic libraries to compile with:  
`odin build more-examples/raylib/game_of_life -define:RAYLIB_SHARED=true`

From a `guix shell`, assuming you have defined a `manifest.scm` with the expected libraries, you need to prepend the execution with the path of the required library:  
`LD_LIBRARY_PATH=$LIBRARY_PATH ./game_of_life`

Finally it also works for Raylib.

---

<div class="post-metadata">

**Author:** ![daviwil](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/daviwil/32/1_2.png) [@daviwil](https://forum.systemcrafters.net/u/daviwil)\
**Post date:** [February 23, 2025, 10:01am UTC](https://forum.systemcrafters.net/t/a-new-experimental-package-for-odin/1370/3 "2025-02-23T10:01:14Z")

</div>

Hey Arnaud, this is cool! Do you think you’ll try to submit the package to Guix at some point?

---

<div class="post-metadata">

**Author:** ![altomcat](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/altomcat/32/583_2.png) [@altomcat](https://forum.systemcrafters.net/u/altomcat)\
**Post date:** [February 23, 2025, 11:21am UTC](https://forum.systemcrafters.net/t/a-new-experimental-package-for-odin/1370/4 "2025-02-23T11:21:09Z")

</div>

Good morning @daviwil,

This is a good question and a long answer to disgress.  
Firstly, but you already know this, it’s a long process to commit patches.  
It takes times to prepare them and depending on the reviewer, it can be processed quickly for a small fix or sunk into the depth of the existing list of patches. My previous official patch to add `guile-raylib` is one of them.  
Secondly, I’m missing some enthousiasm at the moment.  
Currently, it’s quite experimental. I need to provide a replacement for the existing static libraries from the odin’s vendor path. I passed the previous week to create static library packages for `raylib`, `box2d` and `glfw`.  
I added this morning a dedicated phase to compile the `stb` libraries.  
When I’ve finished to build all the samples from [there](https://github.com/odin-lang/examples) , maybe I’ll reconsider and formalize this work.

Eventually, it has been a great challenge to grasp all of the potential of Guix to provide functional and reproducible packages and I learnt a lot.
