3
votes

I am using the IDE Netbeans to code a project c++ under Linux(red hat 7). As I need to use some math functions, I try to embed the julia language into my c++ project.

Here is what I have done:

Download the Julia from here (I choose this: Generic Linux binaries)

Set project properties: build-->C++ Complier-->Include Directories, add the include of Julia, something like this: ../myjulia/include/julia

Add the libraries: open a terminal and type the command line: sudo ln -s ../myjulia/lib/julia/libjulia.so /usr/lib/libjulia.so

Now if I run my project, I will get this error: System image file "../myproject/dist/Debug/GNU-Linux-x86/../lib/julia/sys.ji" not found

I hve checked this file: ../myjulia/lib/julia, in this file, there are all of the lib files (libjulia.so etc) and a file named "sys.ji".

2
Does julia run fine from a commandline? - rickhg12hs
@rickhg12hs the problem has been solved. the problem is that we shouldn't use jl_init(); we should use jl_init_with_image("thePathOfSys.ji", "sys.ji"); - Yves
@rickhg12hs Yes -sorry. Will delete shortly. - Brian Tompsett - 汤莱恩

2 Answers

4
votes

I ran into this issue after installing Julia v0.3.10 on a Windows machine and thought I'd post it in case it can help someone else.

When I ran julia.exe it gave me the error message listed above.

Problem:

I had created a system environment variable called JULIA_HOME and pointed it to the directory where Julia was installed. Then, I added %JULIA_HOME%\bin to my PATH.

Solution:

I pointed JULIA_HOME to the \bin directory under the Julia install directory. Then, I added %JULIA_HOME% to my PATH

2
votes

A "hello world" example from here

Now we know that we need to setup the julia context with this code:

jl_init(NULL);

In fact this code may not setup a good context because the project can't find the system image file "sys.ji". So what we need to do is using another function instead of jl_init: jl_init_with_image. This function accept two parameters: the first is the path of the image file, the second is the name of the image file. So we should use it like this: jl_init_with_image("/thePathOfSys.ji", "sys.ji"); One more thing: the path of sys.ji must be the absolute path.