You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not really an issue, but it would be nice to have an embedding example of Julia into C++. This is an absolute need in large c++ projects as it's easier to embed julia in a sub-project, rather than wrapping the entire C++ project for julia.
I have the impression this is already possible with the existing libcxxwrap-julia framework.
Let's say we have a class like the one you use in types.cpp. Of course, we would like to work with World in both Julia and C++.
function say(w::World)
return w.greet()
end
function better(w::World)::World
return World(greet(w) * " happy people")
end
We have an object of the class World already initialized by C++ and we would like to pass this object to the above julia functions to do some work. Now we want these julia functions to be called by c++. How can we do this?
int main()
{
w = World("hello");
s = // how to call the julia method say with the c++ object w as parameter.
std::cout << s << std::endl;
bw = //how to call the julia method better with the c++ object w as parameter
std::cout << greet(bw) << std::endl;
}
The text was updated successfully, but these errors were encountered:
MariusDrulea
changed the title
Add an example for embedding
Add a class embedding example
Dec 18, 2022
Not really an issue, but it would be nice to have an embedding example of Julia into C++. This is an absolute need in large c++ projects as it's easier to embed julia in a sub-project, rather than wrapping the entire C++ project for julia.
I have the impression this is already possible with the existing libcxxwrap-julia framework.
Let's say we have a class like the one you use in
types.cpp
. Of course, we would like to work withWorld
in both Julia and C++.Here are two sample julia functions:
We have an object of the class
World
already initialized by C++ and we would like to pass this object to the above julia functions to do some work. Now we want these julia functions to be called by c++. How can we do this?The text was updated successfully, but these errors were encountered: