Following up on @stevengj’s comment, it might be easier to help if we knew a bit more about you’re overall goal. Is your main code in C++? Would you like to run your C++ program, have it pass a value to julia, then have julia compute a result and pass it back to C++?
Or is your main program in julia and you need to call C++ to get some value needed by your julia code? Each of these scenarios requires a different approach. If you’re main program is in julia and you just need to get a value from C++ then you should take @stevengj’s approach, which is to compile your C++ code into a shared library and then use a tool like CxxWrap.jl to call the library fom Julia. Alternatively you could write a C interface for your library and use julia’s builtin
ccall to call your C/C++ code.
If your main code is C++ then you need to use the embedding julia approach. You won’t be able to pass variables from C++ into julia if you’re just making a system call to run a julia script. You’ll have to access julia through its C API, as described in the Embedding Julia docs. I’m afraid there isn’t a simpler way to do it. I would suggest trying to make one of the simple examples in that section of the manual work and then try to adapt to your scenario. Start with the very first example in the section, in which you don’t even pass any arguments to julia. That example will at least let you check that you’re able to include the
julia.h header file and link the julia libraries to your executable. Then move on to trying to pass arguments into functions in base julia. Then once you’re comfortable with all that you can move on to calling your own julia functions.