Reputation: 33
I have more than 5 C++/OpenCV projects and i want to combine them in one project with one GUI.
Exemple : When i click Button1, i get the project1 started etc... First, i tried QT but i had some link problems with the openCV, then i used MFC and i found it complicated because i am having to rewrite parts of the projects. Now i am thinking of using the C#/WPF GUI with C++ .dll, but i still have some questions:
1- Is this idea really possible?
2- How to transform an existing C++ project into a .dll. Should i use the .exe or the .cpp/.h files?
3 - Is there any specific things to do because i am using OpenCV and i am not sure if it can work with C#.
4- Do you have any good tutorial that could help me?
One final thing, please tell me that it is going to be simple task because i spent a long time in coding the projects and i thought that the step of the GUI should be easy!
Thank you
Upvotes: 0
Views: 1150
Reputation: 1540
There are a couple good methods depending on what you want to do. The easiest if you have multiple projects is to create a small program and call Process.Start(example.exe)
. Process.Start() just opens a file in whatever default manner is defined for that extension. Of course, that won't actually be integrated into a single GUI but there's essentially no overhead to it whatsoever.
Your other option is to compile everything into class libraries and add references in the C# application to the resulting .dll files. It's easy then to make calls to the .dll file without the overhead of further implementation.
What it will take to compile your specific projects into class libraries is rather hard to say as it varies depending upon what you can salvage and what will need to be re-implemented in the C# application. The absolute easiest approach would be to scrap the GUI and only worry about the code at this point. Past there you can re-implement the GUI itself using WPF.
Compiling to a .dll file is relatively simple and once .dll files are compiled and a reference is added to the C# application calling methods from the .dll file is as simple as calling from a class in the application itself. I will note that methods will require the public keyword if you want to access them but I'd imagine they most likely do if they're already implemented in a working application.
A great tutorial on generating class libraries in VS11 can be found here: http://msdn.microsoft.com/en-us/library/vstudio/ms235636.aspx
Upvotes: 1