# Undefined reference to \`ray::Init()'

**URL:** https://discuss.ray.io/t/undefined-reference-to-ray-init/23554
**Category:** Uncategorized
**Created:** [May 25, 2026, 7:37am UTC](https://discuss.ray.io/t/undefined-reference-to-ray-init/23554 "2026-05-25T07:37:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zlk12142](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/zlk12142/32/8509_2.png) [@zlk12142](https://discuss.ray.io/u/zlk12142)
#### Post date: [May 25, 2026, 7:37am UTC](https://discuss.ray.io/t/undefined-reference-to-ray-init/23554/1 "2026-05-25T07:37:02Z")

</div>

oct1158@DESKTOP-UCV8LC8 /cygdrive/d/Code/C++/Ray/first  
$ ls  
Makefile test.cpp test\_internal.cpp

oct1158@DESKTOP-UCV8LC8 /cygdrive/d/Code/C++/Ray/first  
$ make  
cp C:/Users/qwert2180/AppData/Local/Programs/Python/Python310/Lib/site-packages/ray/cpp/lib/libray\_api.so libray\_api.so  
cp C:/Users/qwert2180/AppData/Local/Programs/Python/Python310/Lib/site-packages/ray/cpp/lib/libray\_api.so ray\_api.dll  
g++ test\_internal.cpp -o test\_internal -D\_GLIBCXX\_USE\_CXX11\_ABI=0 -IC:/Users/qwert2180/AppData/Local/Programs/Python/Python310/Lib/site-packages/ray/cpp/include -L. -lray\_api  
g++ test.cpp -o test -D\_GLIBCXX\_USE\_CXX11\_ABI=0 -IC:/Users/qwert2180/AppData/Local/Programs/Python/Python310/Lib/site-packages/ray/cpp/include -L. -lray\_api  
/usr/lib/gcc/x86\_64-pc-cygwin/13/../../../../x86\_64-pc-cygwin/bin/ld: /tmp/ccrLaO7V.o:test.cpp:(.text+0x233): undefined reference to `ray::Init()' /usr/lib/gcc/x86_64-pc-cygwin/13/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccrLaO7V.o:test.cpp:(.text+0x323): undefined reference to `ray::Shutdown()’  
collect2: error: ld returned 1 exit status  
make: \*\*\* [Makefile:9: test] Error 1

oct1158@DESKTOP-UCV8LC8 /cygdrive/d/Code/C++/Ray/first  
$ ls  
Makefile ray\_api.dll test\_internal.cpp  
libray\_api.so test.cpp test\_internal.exe

oct1158@DESKTOP-UCV8LC8 /cygdrive/d/Code/C++/Ray/first  
$ ./test\_internal  
Segmentation fault

oct1158@DESKTOP-UCV8LC8 /cygdrive/d/Code/C++/Ray/first  
$

【Environment】  
Windows 11 + Python 3.10.11 + cygwin

【Makefile】  
RAY\_CPP\_DIR=C:/Users/qwert2180/AppData/Local/Programs/Python/Python310/Lib/site-packages/ray/cpp

all: test\_internal test

test\_internal: test\_internal.cpp ray\_api.dll  
$(CXX) test\_internal.cpp -o test\_internal -D\_GLIBCXX\_USE\_CXX11\_ABI=0 -I$(RAY\_CPP\_DIR)/include -L. -lray\_api

test: test.cpp ray\_api.dll  
$(CXX) test.cpp -o test -D\_GLIBCXX\_USE\_CXX11\_ABI=0 -I$(RAY\_CPP\_DIR)/include -L. -lray\_api

ray\_api.dll:  
cp $(RAY\_CPP\_DIR)/lib/libray\_api.so libray\_api.so  
cp $(RAY\_CPP\_DIR)/lib/libray\_api.so ray\_api.dll

clean:  
$(RM) test\_internal test libray\_api.so ray\_api.dll

【test\_internal.cpp】  
#include \<ray/api.h\>

extern “C”  
{  
namespace ray  
{  
namespace internal  
{  
msgpack::sbuffer TaskExecutionHandler(const std::string &func\_name, const ArgsBufferList &args\_buffer, msgpack::sbuffer \*actor\_ptr);  
ray::internal::FunctionManager &GetFunctionManager();  
std::pair\<const RemoteFunctionMap\_t &, const RemoteMemberFunctionMap\_t &\> GetRemoteFunctions();  
void InitRayRuntime(std::shared\_ptr runtime);  
}  
}  
}

int main()  
{  
ray::internal::GetFunctionManager();  
ray::internal::GetRemoteFunctions();  
return 0;  
}

【test.cpp】  
#include \<ray/api.h\>  
#include

int MyFunction()  
{  
return 1;  
}  
RAY\_REMOTE(MyFunction);  
int SlowFunction()  
{  
std::this\_thread::sleep\_for(std::chrono::seconds(10));  
return 1;  
}  
RAY\_REMOTE(SlowFunction);

int main()  
{  
ray::Init();

```auto
ray::ObjectRef res = ray::Task(MyFunction).Remote();
std::shared_ptr<int> value = res.Get();
std::cout << "value=" << *value << std::endl;

for (int i = 0; i < 4; i++)
    ray::Task(SlowFunction).Remote();

ray::Shutdown();
return 0;

```

}

---

<div class="post-metadata">

### Author: ![RunLLM](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/runllm/32/8249_2.png) [@RunLLM](https://discuss.ray.io/u/RunLLM)
#### Post date: [May 25, 2026, 7:37am UTC](https://discuss.ray.io/t/undefined-reference-to-ray-init/23554/2 "2026-05-25T07:37:25Z")

</div>

Ray’s C++ API is **not supported on Windows** (including Cygwin), which is the root cause of your build and runtime errors. The official documentation and codebase state that the C++ API is experimental and **only supported on Linux**. Attempting to use it on Windows (even via Cygwin) will result in linker errors and segmentation faults, as you observed ([source](https://github.com/ray-project/ray/blob/master/python/ray/scripts/scripts.py), [source](https://discuss.ray.io/t/c-api-running-example-and-cluster-mode-test-segfaults-on-mac-os/1665)).

If you need to use Ray’s C++ API, you must use a **Linux environment** (native or via WSL2). There is no workaround for Windows at this time. Would you like more detail on setting up Ray C++ on Linux?

Sources:

- [https://github.com/ray-project/ray/blob/master/python/ray/scripts/scripts.py](https://github.com/ray-project/ray/blob/master/python/ray/scripts/scripts.py)
- [https://discuss.ray.io/t/c-api-running-example-and-cluster-mode-test-segfaults-on-mac-os/1665](https://discuss.ray.io/t/c-api-running-example-and-cluster-mode-test-segfaults-on-mac-os/1665)

Hint: Mention @RunLLM in the post for followups.

---

<div class="post-metadata">

### Author: ![zlk12142](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/zlk12142/32/8509_2.png) [@zlk12142](https://discuss.ray.io/u/zlk12142)
#### Post date: [May 25, 2026, 7:39am UTC](https://discuss.ray.io/t/undefined-reference-to-ray-init/23554/3 "2026-05-25T07:39:04Z")

</div>

Is there any plan to support Windows in the future?
