# Newbie for calling julia c files con c and c++

**URL:** <https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263>\
**Category:** New to Julia\
**Tags:** c\
**Created:** [September 21, 2018, 4:52am UTC](https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263 "2018-09-21T04:52:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noise](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@Noise](https://discourse.julialang.org/u/Noise)\
**Post date:** [September 21, 2018, 4:52am UTC](https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263/1 "2018-09-21T04:52:28Z")

</div>

Hello!  
I want to use julia as a scripting language on a game, im giving my first steps on trying scripting languages on c++.  
Can anyone help me to compile it calling julia.h? Im on windows 7 Dev-c++ 5.11, include directories C:\Julia-1.0.0\include\julia, added ",library C:\Julia-1.0.0\lib added, “library or object” linking to Julia-1.0.0/lib/libjulia.dll.a but it gives the error main.cpp:(.text+0x17): undefined reference to `\_\_imp\_jl\_init’ [Error] ld returned 1 exit status so its a link problem i guess.  
The code i wanna compile is:

```julia
 #include <julia.h>
int main(int argc, char *argv[])
{
    jl_init();
    (void)jl_eval_string("println(sqrt(2.0))");
    jl_atexit_hook(0);
    return 0;
}

```

---

<div class="post-metadata">

**Author:** ![wakeup](https://avatars.discourse-cdn.com/v4/letter/w/c6cbf5/32.png) [@wakeup](https://discourse.julialang.org/u/wakeup)\
**Post date:** [December 3, 2018, 12:10pm UTC](https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263/2 "2018-12-03T12:10:54Z")

</div>

I have the same problem in C, and a similar one with c#. Did you solve it? Thanks

---

<div class="post-metadata">

**Author:** ![Noise](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@Noise](https://discourse.julialang.org/u/Noise)\
**Post date:** [December 8, 2018, 4:52am UTC](https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263/3 "2018-12-08T04:52:28Z")

</div>

I just moved to lua for the task i was doing, simpler and fast. Sorry bro.

---

<div class="post-metadata">

**Author:** ![dm3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dm3/32/2755_2.png) [@dm3](https://discourse.julialang.org/u/dm3)\
**Post date:** [January 23, 2019, 9:48am UTC](https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263/4 "2019-01-23T09:48:29Z")

</div>

Just ran into the same issue after upgrading to Julia 1.1 from 0.6.4 on Windows 10 (mingw toolchain). Investigating now… any tips on what changed in 1.0+ welcome!

---

<div class="post-metadata">

**Author:** ![dm3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dm3/32/2755_2.png) [@dm3](https://discourse.julialang.org/u/dm3)\
**Post date:** [January 23, 2019, 9:58am UTC](https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263/5 "2019-01-23T09:58:02Z")

</div>

solved - need to `#define JULIA_ENABLE_THREADING` before `#include <julia.h>` on Windows. Not very intuitive… identified in [https://github.com/JuliaLang/julia/issues/28969](https://github.com/JuliaLang/julia/issues/28969). The related documentation PR seems to be merged, although it only mentions Visual Studio which might throw some people off.

---

<div class="post-metadata">

**Author:** ![dm3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dm3/32/2755_2.png) [@dm3](https://discourse.julialang.org/u/dm3)\
**Post date:** [January 23, 2019, 10:27am UTC](https://discourse.julialang.org/t/newbie-for-calling-julia-c-files-con-c-and-c/15263/6 "2019-01-23T10:27:16Z")

</div>

Now running into another issue:

 ![52](https://global.discourse-cdn.com/julialang/original/3X/4/5/45553576c755f7f6c21ec027704fbf414305ccc3.png) - any help greatly appreciated!

solved: check that Julia’s provided C++ stdlib is loaded before any other ones get the chance to load 🙂
