From 9e6c2114b30e1f910003fff91c9f91d513f52ecc Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 11:16:56 +0200 Subject: [PATCH 01/11] Debugging macos --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bab5a15..e85a181 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,8 @@ LIBS_DIR := $(abspath ./libs) UNAME_S := $(shell uname -s) # Flags for CGO to find the headers and the shared library -ifeq ($(UNAME_S),Darwin) - CGO_CFLAGS := -I$(LIBS_DIR) - CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,@executable_path/./libs -else - CGO_CFLAGS := -I$(LIBS_DIR) - CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) -endif +CGO_CFLAGS := -I$(LIBS_DIR) +CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) ifeq ($(OS),Windows_NT) BIN_NAME := example.exe From 5b26d4e8326a418a9817bb646da7c00217ebfe2e Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 11:25:28 +0200 Subject: [PATCH 02/11] Debug --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index 149fbe8..de33c4e 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,8 @@ import ( "github.com/codex-storage/codex-go-bindings/codex" ) +// #cgo LDFLAGS: -L${SRCDIR}/libs -llibcodex + func main() { node, err := codex.New(codex.Config{ BlockRetries: 5, From 6e52a7106dd2cb47eb828fc04cf26432db75f971 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 11:29:38 +0200 Subject: [PATCH 03/11] debug --- Makefile | 12 ++++++++++-- main.go | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e85a181..b2586ab 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,13 @@ LIBS_DIR := $(abspath ./libs) UNAME_S := $(shell uname -s) # Flags for CGO to find the headers and the shared library -CGO_CFLAGS := -I$(LIBS_DIR) -CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) +ifeq ($(UNAME_S),Darwin) + CGO_CFLAGS := -I$(LIBS_DIR) + CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,@executable_path/./libs +else + CGO_CFLAGS := -I$(LIBS_DIR) + CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) +endif ifeq ($(OS),Windows_NT) BIN_NAME := example.exe @@ -29,6 +34,9 @@ fetch: rm -f $(LIBS_DIR)/*.zip build: + @echo "CGO_CFLAGS=$(CGO_CFLAGS)" + @echo "CGO_LDFLAGS=$(CGO_LDFLAGS)" + ls -l $(LIBS_DIR) CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BIN_NAME) main.go run: diff --git a/main.go b/main.go index de33c4e..149fbe8 100644 --- a/main.go +++ b/main.go @@ -8,8 +8,6 @@ import ( "github.com/codex-storage/codex-go-bindings/codex" ) -// #cgo LDFLAGS: -L${SRCDIR}/libs -llibcodex - func main() { node, err := codex.New(codex.Config{ BlockRetries: 5, From 5de8ec1728820d6580377462916984e5afb2a7d8 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 11:31:14 +0200 Subject: [PATCH 04/11] Fix indent --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b2586ab..7d7c8b7 100644 --- a/Makefile +++ b/Makefile @@ -34,8 +34,8 @@ fetch: rm -f $(LIBS_DIR)/*.zip build: - @echo "CGO_CFLAGS=$(CGO_CFLAGS)" - @echo "CGO_LDFLAGS=$(CGO_LDFLAGS)" + @echo "CGO_CFLAGS=$(CGO_CFLAGS)" + @echo "CGO_LDFLAGS=$(CGO_LDFLAGS)" ls -l $(LIBS_DIR) CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BIN_NAME) main.go From d2224c1862b5c60c33c4d813f60836509f54a510 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 11:44:38 +0200 Subject: [PATCH 05/11] debug --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 7d7c8b7..121f3fe 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ build: @echo "CGO_CFLAGS=$(CGO_CFLAGS)" @echo "CGO_LDFLAGS=$(CGO_LDFLAGS)" ls -l $(LIBS_DIR) + go env CGO_LDFLAGS CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BIN_NAME) main.go run: From dbb833bbaea10ca9cf63b3e54b526e0998ec0be2 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 11:50:20 +0200 Subject: [PATCH 06/11] debug --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 121f3fe..d1cb7e3 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ UNAME_S := $(shell uname -s) # Flags for CGO to find the headers and the shared library ifeq ($(UNAME_S),Darwin) CGO_CFLAGS := -I$(LIBS_DIR) - CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,@executable_path/./libs + CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,@executable_path/libs else CGO_CFLAGS := -I$(LIBS_DIR) CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) From 0f86992c5b84dead4cb225efe3bc407bf42f1bcd Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 12:07:28 +0200 Subject: [PATCH 07/11] debug --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d1cb7e3..d1d52dd 100644 --- a/Makefile +++ b/Makefile @@ -39,11 +39,13 @@ build: ls -l $(LIBS_DIR) go env CGO_LDFLAGS CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BIN_NAME) main.go - run: ifeq ($(OS),Windows_NT) pwsh -Command "Copy-Item libs\libcodex.dll ." pwsh -Command ".\$(BIN_NAME)" +else ifeq ($(UNAME_S),Darwin) + otool -L libs/libcodex.dylib + DYLD_LIBRARY_PATH=$(LIBS_DIR) ./$(BIN_NAME) else ./$(BIN_NAME) endif From 0ed267cdb69ce2ffc1c982948a9c14d8f08a4893 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 12:12:23 +0200 Subject: [PATCH 08/11] Debug --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d1d52dd..3260c27 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,9 @@ fetch: @curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${LATEST_URL} unzip -o -qq $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d $(LIBS_DIR) rm -f $(LIBS_DIR)/*.zip - +ifeq ($(UNAME_S),Darwin) + install_name_tool -id @rpath/libcodex.dylib libs/libcodex.dylib +endif build: @echo "CGO_CFLAGS=$(CGO_CFLAGS)" @echo "CGO_LDFLAGS=$(CGO_LDFLAGS)" @@ -44,8 +46,8 @@ ifeq ($(OS),Windows_NT) pwsh -Command "Copy-Item libs\libcodex.dll ." pwsh -Command ".\$(BIN_NAME)" else ifeq ($(UNAME_S),Darwin) - otool -L libs/libcodex.dylib - DYLD_LIBRARY_PATH=$(LIBS_DIR) ./$(BIN_NAME) +# DYLD_LIBRARY_PATH=$(LIBS_DIR) ./$(BIN_NAME) + ./$(BIN_NAME) else ./$(BIN_NAME) endif From cfeeb3fc294d1655bde7dc4554aea5ad284e660d Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 12:15:38 +0200 Subject: [PATCH 09/11] Debug --- Makefile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 3260c27..a965338 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,9 @@ # Destination folder for the downloaded libraries LIBS_DIR := $(abspath ./libs) -UNAME_S := $(shell uname -s) - # Flags for CGO to find the headers and the shared library -ifeq ($(UNAME_S),Darwin) - CGO_CFLAGS := -I$(LIBS_DIR) - CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,@executable_path/libs -else - CGO_CFLAGS := -I$(LIBS_DIR) - CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) -endif +CGO_CFLAGS := -I$(LIBS_DIR) +CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) ifeq ($(OS),Windows_NT) BIN_NAME := example.exe @@ -33,7 +26,7 @@ fetch: unzip -o -qq $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d $(LIBS_DIR) rm -f $(LIBS_DIR)/*.zip ifeq ($(UNAME_S),Darwin) - install_name_tool -id @rpath/libcodex.dylib libs/libcodex.dylib + install_name_tool -id @rpath/libcodex.dylib $(LIBS_DIR)/libcodex.dylib endif build: @echo "CGO_CFLAGS=$(CGO_CFLAGS)" From 3633146b09d698fb110025a90e70daad7ab4a087 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 12:16:26 +0200 Subject: [PATCH 10/11] Debug --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a965338..e4ff0bb 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,15 @@ # Destination folder for the downloaded libraries LIBS_DIR := $(abspath ./libs) +UNAME_S := $(shell uname -s) # Flags for CGO to find the headers and the shared library -CGO_CFLAGS := -I$(LIBS_DIR) -CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) +ifeq ($(UNAME_S),Darwin) + CGO_CFLAGS := -I$(LIBS_DIR) + CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,@executable_path/libs +else + CGO_CFLAGS := -I$(LIBS_DIR) + CGO_LDFLAGS := -L$(LIBS_DIR) -lcodex -Wl,-rpath,$(LIBS_DIR) +endif ifeq ($(OS),Windows_NT) BIN_NAME := example.exe From 703180f835437764f05052ebabb7a2258ddf0711 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 15 Oct 2025 12:18:51 +0200 Subject: [PATCH 11/11] Debug --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e4ff0bb..4df4b6a 100644 --- a/Makefile +++ b/Makefile @@ -28,24 +28,24 @@ all: run fetch: @echo "Fetching libcodex from GitHub Actions: ${LATEST_URL}" - @curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${LATEST_URL} + curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${LATEST_URL} unzip -o -qq $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d $(LIBS_DIR) rm -f $(LIBS_DIR)/*.zip +# Update the path to the shared library on macOS ifeq ($(UNAME_S),Darwin) install_name_tool -id @rpath/libcodex.dylib $(LIBS_DIR)/libcodex.dylib endif + build: - @echo "CGO_CFLAGS=$(CGO_CFLAGS)" - @echo "CGO_LDFLAGS=$(CGO_LDFLAGS)" - ls -l $(LIBS_DIR) - go env CGO_LDFLAGS CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BIN_NAME) main.go + run: ifeq ($(OS),Windows_NT) pwsh -Command "Copy-Item libs\libcodex.dll ." pwsh -Command ".\$(BIN_NAME)" else ifeq ($(UNAME_S),Darwin) -# DYLD_LIBRARY_PATH=$(LIBS_DIR) ./$(BIN_NAME) +# Instead of relying on install_name_tool, we can define DYLD_LIBRARY_PATH +# DYLD_LIBRARY_PATH=$(LIBS_DIR) ./$(BIN_NAME) ./$(BIN_NAME) else ./$(BIN_NAME)