Closed alichay closed 7 years ago
This should perfectly possible already:
#foreign_system_library "sdl2.lib" when ODIN_OS == "windows";
#foreign_system_library "SDL2" when ODIN_OS == "linux";
Okay, I feel like an idiot. I got the syntax wrong. Thanks!
I found the original problem I had. I thought it failed to compile because I had used a 'when' on a foreign_system_library, but the problem is actually in having two libraries with the same name, even if only one is being included.
5: #foreign_system_library sdl "SDL2.lib" when (ODIN_OS == "windows");
6: #foreign_system_library sdl "-lSDL2" when (ODIN_OS == "osx" || ODIN_OS == "linux");
fails with
keel/libraries/sdl.odin(6:25) Redeclararation of `sdl` in this scope
at keel/libraries/sdl.odin(5:25)
This bug will be fixed in the next commit. Also, I'd remove the -l
and let the compile add them. It's cleaner and more "portable".
When making bindings for libraries that are platform independent (let's take SDL2 for example), it would be nice to have some way of signaling that for Linux you want to link with "-lSDL2" but for Win32 you'll want to link with "sdl2.lib"
This is a very low priority issue, and it can be worked around by conditionally loading files that just act to link with the library, but it's something that would be nice to have.