Yin Zhu
Yin Zhu

Reputation: 17119

C# for UI, c++ for library

I have a numerical library coded in C++.

I am going to make a UI for the library. I know some MFC. So one solution is to use MFC and make a native application.

The alternative is C#. I know nothing about C#. But I think it should be easy to learn.

Some tutorial for mixed programming of C++ and C# would be very helpful to me.

Thanks!

Yin

Upvotes: 3

Views: 1348

Answers (6)

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93424

If you have the source to your C++ numerical library, you can modify it to compile as C++/CLI then you can link to it just like any other .NET library. It shouldn't require a large amount of work to modify the source with #defines for C++/CLI conditional compiling.

Upvotes: 0

Stephen Newell
Stephen Newell

Reputation: 7828

I'd suggest looking into SWIG. You can write the core part of your code in C++ as a dll, then have a C# UI link against it.

Upvotes: 0

Massimiliano
Massimiliano

Reputation: 16980

Write your GUI in C# using WinForms or WPF, and call your native code through Platform Invoke.

Instead of P/Invoke, you might want to consider C++/CLI to make a .NET wrapper for your native library.

IMHO using C# is MUCH more easier than MFC, so you are on the right track.

Upvotes: 3

BostonLogan
BostonLogan

Reputation: 1596

Go with C#. MFC is somewhat dated, so if you need to learn something - go for newer technology, do not waste your time with MFC. I'd go for WPF, learning curve is rather steep, but its fun.

Upvotes: 0

TheSean
TheSean

Reputation: 4566

You can use C# very easily to make the UI. You'll need to write a simple wrapper class to call your unmanaged dll, but that is straightforward. check out the msdn page on that subject

Upvotes: 1

Reed Copsey
Reed Copsey

Reputation: 564323

I would recommend using Windows Forms or WPF via C# for your GUI.

Take your numerical library, and use C++/CLI to make a .NET wrapper for it. This makes it trivial to use from C# (it looks like any other C# library).

I highly recommend Nishant Sivakumar's C++/CLI articles on CodeProject for learning about C++/CLI and how to wrap C++ libraries. They're fairly well written.

MSDN is a good reference for how to use Windows Forms from C#.

Upvotes: 8

Related Questions