5

My intention is to take a C++ library, wrap it for C# with SWIG (alt. link), and compile both C++ and C# components as DLLs for Unity 5. (The C# DLL provides Unity with an interface to the C++ DLL.)

To the best of my knowledge, compiling C++ and C# DLLs always requires Visual Studio (or tools like msbuild that come with VS). However, I am currently struggling to get VS installed, which has led me to question that assumption.

Are there any other options for compiling Unity-ready DLLs on Windows?

(Even if I get VS installed, I'm still curious to know.)

lofidevops
  • 15,528
  • 14
  • 79
  • 119
  • 4
    You do know that you can get free ("gratis") Visual Studio (Express) with all tools needed, and even use it for [commercial purposes](https://social.msdn.microsoft.com/Forums/en-US/1aaf1efc-04df-40b9-9289-f3db0420c206/visual-studio-2012-express?forum=Vsexpressinstall). – Some programmer dude Jul 17 '15 at 12:16
  • 2
    Full *Visual Studio Community* is also gratis – Alex K. Jul 17 '15 at 12:20

4 Answers4

4

You can download a stand alone version of MSBuild and use that to compile you code, you don't need VS for that.

There's a walkthrough here:

msbuild buildapp.csproj /t:HelloWorld
Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
  • 2
    You can get it to work with Visual C++ as well, but it's a lot of work and you'll easily end up in a bad place regarding MSVCRT. Disk space is a lot less valuable than your time and sanity. – GeirGrusom Jul 17 '15 at 12:39
  • @cup No. [MSBuild is used for C++ compilation as well](https://msdn.microsoft.com/en-us/library/dd293607.aspx). – Yuval Itzchakov Jul 17 '15 at 13:09
  • @YuvalItzchakov Not very clear whether the OP needs to build C++ as well. If you look at the article, it says one of the prerequisites is VS2013 must be installed. MSBuild only comes with C# and VB. If the OP only needs to build C#, this will work but if he needs to build C++ as well, he will run into the same problems trying to install VS. – cup Jul 17 '15 at 17:10
  • @cup I've read the article. VS is a prerequisite just to generate the code, it has nothing to do with the compilation process: *You can create these C++ files by using Visual Studio or a **text editor**.* – Yuval Itzchakov Jul 17 '15 at 17:12
2

Use command line tools like csc (C# Compler), they have everything to do the job, you do not need anything else, check this out the Link.

You just need to install .Net framework to get the compiler no VS or any other tool required. It has switch for every option provided by VS.

In case you need assembly linking use the Assembly Linker tool Link.

Check the following Link on ILMerge too

Community
  • 1
  • 1
Mrinal Kamboj
  • 11,300
  • 5
  • 40
  • 74
2

Yes, you can use MinGW to compile C++ to a DLL from the commandline.

If you prefer a GUI interface, you might try Code::Blocks. It comes bundled with a tweaked version of MinGW, but since it's a GUI-based IDE you don't have to interact with it directly :)

However, you'll still need to get your swig-wrapped code into a C# DLL. I'd investigate whether MonoDevelop can achieve this.

EDIT: Just seen ReCoF's answer - it seems you can use MonoDevelop for the C# side of things so you're good to go :)

Katherine Rix
  • 672
  • 2
  • 8
  • 18
  • In my case the library is maintained primarily against gcc, so this also means no new issues just because I'm compiling on a new platform :) Yay! – lofidevops Jul 23 '15 at 10:13
1

You can also compile your project with MonoDevelop. You just have to choose the Release Mode instead of the Debug one.

ReCoF
  • 108
  • 7
  • I understand this post tag is Visual-Studio, but if you have problem to get Visual, this is another way to get the result you want. – ReCoF Jul 17 '15 at 14:24