I am trying to build an application where C++ is the host language and where some functions implemented in Rust are called from C++.
Like all applications, this one, too, has a unique main entry point called main().
As I am new to Rust and CXX Bridge, the problem I'm facing is that all sample code I have found on Google implements this main() function in the Rust part of the project, while I want it implemented in the C++ part of it.
For debugging purposes and as a workaround, I have added a function cppmain() in the C++ code. The Rust main() then calls that cppmain() which in turn calls the Rust function I want to test:
User launches app --> app entered at Rust main() --> C++ cppmain() --> Rust test function
This works for testing but is not what I ultimately need.
What I ultimately want is to remove the Rust main(), and in exchange make cppmain() the official main() of the application (essentially by renaming it to main()):
User launches app --> app entered at C++ main() --> Rust test function
However, I have not succeeded in this. The CXX Bridge seems to expect a main.rs file with the Rust main() inside, and if this is not the case, the build fails (using cargo).
If somebody knows how to solve this problem please let me know. Thanks, Mario