There is a toolchain for coding stuff for the 3DS, which comes with its own compiler, linker, standard library, other libraries, etc. The compiler it comes with is called arm-none-eabi-gcc.
And there is this library called libctru, which is responsible for most stuff interfacing with the 3DS.
I managed to make it work properly, by making a Odin module using the foreign keyword, to interface with the function definitions of the library. The game loop works and it can respond to input.
However, the problem is Odin itself. I can't print anything that it ends up crashing the 3DS (or causing a segfault). I think the Odin's fmt library wasn't made to interface properly with the 3DS.
this is the build script i have so far:
#!/bin/bash
odin build . \
-target-features:soft-float \
-microarch:generic \
-target:linux_arm32 \
-build-mode:object \
-use-single-module \
-linker:lld \
$DEVKITARM/bin/arm-none-eabi-gcc -o odin-teste.elf \
odin-teste.o \
-specs=3dsx.specs \
-g \
-Wall \
-O2 \
-mword-relocations \
-ffunction-sections \
-D__3DS__ \
-march=armv6k \
-mtune=mpcore \
-mfloat-abi=hard \
-mtp=soft \
-Wl,-Map,odin-teste.map \
-L$DEVKITPRO/libctru/lib \
-lctru -lm
3dsxtool odin-teste.elf odin-teste.3dsx
Honestly, it might be because of the target i chose, linux_arm32. The 3DS is ARM, so this is the closest I could find. But this doesn't mean the 3DS works like Linux does.
Theres also freestanding_arm32, which could be the recommended option, but the problem is that it can't recognize printf from the fmt anymore, and it can't find the entry point anymore, for some reason.
When making the build script, I took as a reference a basic example makefile to build a project on the 3DS:
https://github.com/devkitPro/3ds-examples/blob/master/templates/application/Makefile