Specific install_name for macOS

This commit is contained in:
Arnaud 2025-10-15 13:34:35 +02:00 committed by Eric
parent c08a774216
commit 4af8b9d60e
No known key found for this signature in database
2 changed files with 20 additions and 5 deletions

View File

@ -266,7 +266,7 @@ else ifeq ($(detected_OS),Windows)
$(ENV_SCRIPT) nim libcodexDynamic $(NIM_PARAMS) -d:LeopardCmakeFlags="\"-G \\\"MSYS Makefiles\\\" -DCMAKE_BUILD_TYPE=Release\"" codex.nims
else ifeq ($(detected_OS),macOS)
echo -e $(BUILD_MSG) "build/$@.dylib" && \
$(ENV_SCRIPT) nim libcodexDynamic $(NIM_PARAMS) -d:LeopardCmakeFlags="\"-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release\"" codex.nims
$(ENV_SCRIPT) nim libcodexDynamic $(NIM_PARAMS) -d:LeopardCmakeFlags="\"-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release\"" --passL:"-install_name @rpath/libs/libcodex.dylib" codex.nims
else
echo -e $(BUILD_MSG) "build/$@.so" && \
$(ENV_SCRIPT) nim libcodexDynamic $(NIM_PARAMS) -d:LeopardCmakeFlags="\"-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release\"" codex.nims

View File

@ -91,10 +91,6 @@ Run the example:
By default, Codex builds a dynamic library (`libcodex.so`), which you can load at runtime.
If you prefer a static library (`libcodex.a`), set the `STATIC` flag:
### Limitation
Callbacks must be fast and non-blocking; otherwise, the working thread will hang and prevent other requests from being processed.
```bash
# Build dynamic (default)
make libcodex
@ -103,6 +99,25 @@ make libcodex
make STATIC=1 libcodex
```
### Limitation
Callbacks must be fast and non-blocking; otherwise, the working thread will hang and prevent other requests from being processed.
### Platform specific
On macOS, the library is built with `-install_name @rpath/libs/libcodex.dylib` to have the `libs` folder as default
path for the artifacts. This can be updates by the application consuming the library using:
```sh
install_name_tool -id @rpath/libcodex.dylib $(CUSTOM_FOLDER)/libcodex.dylib
```
Or when running the executable:
```sh
DYLD_LIBRARY_PATH=$(CUSTOM_FOLDER) ./app
```
## Contributing and development
Feel free to dive in, contributions are welcomed! Open an issue or submit PRs.