Add custom linking overrides #1390
Replies: 3 comments 3 replies
-
|
It's not a bad idea to override possible libraries. I'm not sure on the syntax on whether it should be source level, or command line level, or both. But in general, the idea should work perfectly fine since it's just a basic text substitution problem. |
Beta Was this translation helpful? Give feedback.
-
Do you mean replacing dynamic library with a custom-built static library? |
Beta Was this translation helpful? Give feedback.
-
|
Bumping this discussion since I ran into this issue recently - another alternative would just be to have the vendored libraries support // vendor/sdl3/sdl3__foreign.odin
package sdl3
when ODIN_OS == .Windows {
DEFAULT_LIBRARY_PATH :: "SDL3.lib"
} else {
DEFAULT_LIBRARY_PATH :: "system:SDL3"
}
LIBRARY_PATH :: #config(SDL3_PATH, DEFAULT_LIBRARY_PATH)
when LIBRARY_PATH != DEFAULT_LIBRARY_PATH {
// logic for foreign importing and linking with required system libraries, for example:
when ODIN_OS == .Darwin && LIBRARY_PATH[:len(LIBRARY_PATH) - len(".a")] == ".a" {
@(export)
foreign import lib {"system:" + LIBRARY_PATH, "system:Cocoa.framework", "system:OpenGL.framework", "system:IOKit.framework", "system:AVFoundation.framework", "system:CoreAudio.framework", "system:AudioToolbox.framework", "system:CoreHaptics.framework", "system:CoreMedia.framework", "system:Metal.framework", "system:GameController.framework", "system:ForceFeedback.framework", "system:Carbon.framework", "system:CoreVideo.framework", "system:QuartzCore.framework", "system:UniformTypeIdentifiers.framework"}
// etc.
}
} else {
// existing code
}Then users could run the code with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently a number of vendor packages link to libraries be it
system:someliborsomelib.lib. However they are all shared, and require to be distributed with the executable, or to be present in the system. It would be better to just have 1 executable without much dependencies, for which I would use my own library. A couple of solutions I see:Solution 1 (not ideal)
Copy the whole package to my project folder, and change every
importto the library I need.Problems:
sed -ibut a tad bizzare.ospackage if you don't like the standard one, but that seems like a bit of an overkill for this scenario.Solution 2 (proposal)
Introduce a flag/source code tag/etc that lets me change every library link to another, i.e.
or
I think adding a flag to the compiler is preferred, since it's unclear how the code would behave if
#replacelibwas called in several places.Beta Was this translation helpful? Give feedback.
All reactions