# Error compiling C code that runs Julia code

**URL:** https://discourse.julialang.org/t/error-compiling-c-code-that-runs-julia-code/90694
**Category:** General Usage
**Tags:** c
**Created:** [November 23, 2022, 9:56am UTC](https://discourse.julialang.org/t/error-compiling-c-code-that-runs-julia-code/90694 "2022-11-23T09:56:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nvenkov1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nvenkov1/32/43679_2.png) [@nvenkov1](https://discourse.julialang.org/u/nvenkov1)
#### Post date: [November 23, 2022, 9:56am UTC](https://discourse.julialang.org/t/error-compiling-c-code-that-runs-julia-code/90694/1 "2022-11-23T09:56:45Z")

</div>

My Julia folder is /home/nxf93431/julia-1.8.1/ and I write the following main.c file in C:

```julia
#include <julia.h>
JULIA_DEFINE_FAST_TLS

int main(int argc, char *argv[]) {
  jl_init();
  jl_eval_string("print(sqrt(2.))");
  jl_atexit_hook(0);
  return 0;
}

```

Then I try to compile as follows:

```julia
gcc -o main -fPIC -I$/home/nxf93431/julia-1.8.1/include/julia -L$/home/nxf93431/julia-1.8.1/lib -Wl,-rpath,$/home/nxf93431/julia-1.8.1/lib main.c -ljulia

```

but unfortunately, I get a compilation error that says “fatal error: julia.h: No such file or directory”.  
I do not understand why I get this error since I specify the path in my compilation line.

---

<div class="post-metadata">

### Author: ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)
#### Post date: [November 23, 2022, 10:05am UTC](https://discourse.julialang.org/t/error-compiling-c-code-that-runs-julia-code/90694/2 "2022-11-23T10:05:46Z")

</div>

I think the ‘$’ characters are too much here: Either use

```julia
-I$HOME/julia-1.8.1/include/julia

```

or the expansion of the ‘$HOME’ shell variable

```julia
-I/home/nxf93431/julia-1.8.1/include/julia

```
