Embedding Julia C question

embedding

#1

Hi,
I am struggling with the documentation on embedding Julia in C. Is there an obvious thing I am doing wrong?
If I try the test example in: https://docs.julialang.org/en/v1/manual/embedding/index.html
i.e. calling:

JULIA_DIR=/home/julia-1.0.2
gcc -o test -fPIC -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib test.c -ljulia $JULIA_DIR/lib/julia/libstdc++.so.6

I get the result in the terminal:

/tmp/cccutk9I.o: In function `main':
test.c:(.text+0x10): undefined reference to `jl_init'
collect2: error: ld returned 1 exit status

When I try the same on the server I get a different result in the terminal:

In file included from /home/julia-1.0.2/include/julia/julia.h:1619,
                 from test.c:1:
/home/julia-1.0.2/include/julia/locks.h: In function âjl_mutex_waitâ:
/home/julia-1.0.2/include/julia/locks.h:24: error: â__ATOMIC_ACQUIREâ undeclared (first use in this function)
/home/julia-1.0.2/include/julia/locks.h:24: error: (Each undeclared identifier is reported only once
/home/julia-1.0.2/include/julia/locks.h:24: error: for each function it appears in.)
/home/julia-1.0.2/include/julia/locks.h:37: error: â__ATOMIC_SEQ_CSTâ undeclared (first use in this function)
/home/julia-1.0.2/include/julia/locks.h: In function âjl_mutex_lockâ:
/home/julia-1.0.2/include/julia/locks.h:102: error: â__ATOMIC_SEQ_CSTâ undeclared (first use in this function)
/home/julia-1.0.2/include/julia/locks.h: In function âjl_mutex_unlock_nogcâ:
/home/julia-1.0.2/include/julia/locks.h:126: error: â__ATOMIC_SEQ_CSTâ undeclared (first use in this function)
/home/julia-1.0.2/include/julia/locks.h:126: error: â__ATOMIC_RELEASEâ undeclared (first use in this function)
/home/julia-1.0.2/include/julia/locks.h: In function âjl_mutex_unlockâ:
/home/julia-1.0.2/include/julia/locks.h:138: error: â__ATOMIC_SEQ_CSTâ undeclared (first use in this function)
In file included from test.c:1:
/home/julia-1.0.2/include/julia/julia.h: In function âjl_eh_restore_stateâ:
/home/julia-1.0.2/include/julia/julia.h:1645: error: â__ATOMIC_SEQ_CSTâ undeclared (first use in this function)

If I try the example in test/embedding (https://github.com/JuliaLang/julia/tree/master/test/embedding). I get this error:

ib/julia/libstdc++.so.6
/usr/bin/ld: /tmp/ccJPgarI.o: undefined reference to symbol 'sqrt@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing
from command line
collect2: error: ld returned 1 exit status

and for the server the same error it have above.

Also is there a working example for Windows? On windows the file : julia-1.0.2/lib/julia/libstdc++.so.6 doesn’t exist. A working example would be great.

Cheers,
Tim