# Loading julia shared library in C on Windows

**URL:** <https://discourse.julialang.org/t/loading-julia-shared-library-in-c-on-windows/7242>\
**Category:** Internals & Design\
**Created:** [November 22, 2017, 8:10am UTC](https://discourse.julialang.org/t/loading-julia-shared-library-in-c-on-windows/7242 "2017-11-22T08:10:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![randy3k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/randy3k/32/878_2.png) [@randy3k](https://discourse.julialang.org/u/randy3k)\
**Post date:** [November 22, 2017, 8:10am UTC](https://discourse.julialang.org/t/loading-julia-shared-library-in-c-on-windows/7242/1 "2017-11-22T08:10:13Z")

</div>

I am trying to load the julia shared library in C on Windows using the following C code. And the returned pointer is `NULL` no matter what I tried.

```nohighlight
#include <Windows.h>
#include <stdio.h>

int main() {
	int status = 0;
    HINSTANCE plib;
    plib = LoadLibrary("C:\\Users\\IEUser\\AppData\\Local\\JULIA-~1.1\\bin\\julia.exe");
	printf("%p\n", (void*) plib);
    return 0;
}

```

I am sure that `julia.exe` can be opened as I could use `ctypes.CDLL` to open it in python.

```julia
In [1]: import ctypes

In [2]: ctypes.CDLL("C:\\Users\\IEUser\\AppData\\Local\\JULIA-~1.1\\bin\\julia.exe")
Out[2]: <CDLL 'C:\Users\IEUser\AppData\Local\JULIA-~1.1\bin\julia.exe', handle 400000 at 0x1baf6170630>

```

Does anyone have any experiences on this matter?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [November 22, 2017, 10:04pm UTC](https://discourse.julialang.org/t/loading-julia-shared-library-in-c-on-windows/7242/2 "2017-11-22T22:04:40Z")

</div>

Is there a specific reason you are trying to load the exe? You can’t do that without some [hacks](https://stackoverflow.com/questions/19110747/loadlibrary-an-exe). Use libjulia[.dll], as documented in the embedding section of the manual and demonstrated in the embedding test (which shows usage from C).
