From ddf3909fed190344d478c4e5dda30e6ede4f9b09 Mon Sep 17 00:00:00 2001 From: Wenqi Chen Date: Sun, 22 Jan 2023 19:25:09 +0800 Subject: [PATCH] docs: improve the README for examples/call_v_from_c/ with instructions for macos (#17060) --- examples/call_v_from_c/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/call_v_from_c/README.md b/examples/call_v_from_c/README.md index f4f58471c..b6f72eda2 100644 --- a/examples/call_v_from_c/README.md +++ b/examples/call_v_from_c/README.md @@ -13,6 +13,22 @@ Step 2: Compile the c file using `gcc test_print.c v_test_print.so -o test_print Step 3: Run the compiled c file using `LD_LIBRARY_PATH=. ./test_print` or `LD_LIBRARY_PATH=. ./test_math`. + +#### On Mac OSX: + +On Mac OSX, libgc can be obtained from homebrew by `brew install libgc`. +During compiling and/or linking, `-I/usr/local/include -L/usr/local/lib` (for x86_64), +or `-I/opt/homebrew/include -L/opt/homebrew/lib` (for arm64) can be added depending the arch. + +Step 1: Compile the v code to a shared library using `v -cc gcc -shared v_test_print.v` or +`v -cc gcc -shared v_test_math.v`. + +Step 2: Compile the c file using `gcc test_print.c v_test_print.dylib -o test_print` or +`gcc test_math.c v_test_math.dylib -o test_math`. + +Step 3: Run the compiled c file using `LD_LIBRARY_PATH=. ./test_print` or +`LD_LIBRARY_PATH=. ./test_math`. + #### On Windows: Step 1: Compile the v code to a shared library using `v -cc gcc -shared v_test_print.v` or -- 2.30.2