I just want to call/use the rust library or rust functions from rs file in C project. How can i implement it in eclipse ?????????
I have tried from several ways but didn't get success.
below are the things, i did for achieving my target :----
I created a new C project in eclipse having the "hello world" program. I am able to run the same.
Now i created a rust file in the same src folder say lib.rs and write the below function in that file.
Probably the main problem here is the order of the file you are using during the link phase.
Imagine that you created the libadd.a with rust and main.o in C. main.o must precede libadd.a in the linker command.
But the fact is that, in this way, you will get many errors. This because you are creating a static library, and when you link together your files, you will miss many symbols. That's because you are using the rust stdlib with the println! macro, and at to date we don't have a pure rust ecosystem.
If you are on linux (sorry, that's my OS ) you can manually link the pthread and the dl libraries during the link phase. But if you use cdynlib instead of staticlib, you already have the resolution of your symbols, and you can just link the libadd.so (or libadd.dll on windows) to your C project. But I don't know if it is your case
You can use 'rustc' to build your crate as a static or dynamic library and then link with it. I do not use eclipse and I don't know what build system you're using so I don't have specific advice. If you have a cmake project then I could paste some of what I use to integrate cargo into my cmake projects.
There was recently mentioned a new eclipse plugin for Rust called Corrosion. I'd venture to guess that it would be worth trying this out as a solution.