Easy setup to compile CPP on windows with .net and custom libraries

(mh) #1

I tried to challenge myself a little and thought to enter new territory by trying to compile a C++ application from a friend with gradle. (Disclaimer: I had no clue about C++ …)

Either I did something completely wrong or it is way to complex to do it right now in Gradle because it took me far to long to get things compiled.

My sample project: https://dl.dropbox.com/u/19407988/libSampleANE.zip

Here are the three major problems I stumbled into:

  1. CL.exe doesn’t compile without the certain system variables to libraries set (it can’t even find basic std.io libraries). There is a easy way to get them into a console and a hard way: The easy way is through Visual C++ (there is a command line button somewhere) which pre-modifies the command line. The complex way is trying to get things done using the vcvars32.bat which ended in plenty of hiccups for me. (not properly recognized, path to command line, typical configuration stuff I wasn’t familiar with).

  2. The library file (FlashRuntimeExtensions.lib) is provided as a file in a folder. And I am to date not quite sure how to correctly add a dependency like that to the classpath. I used “getLibs().from” but it seems pretty hacky.

  3. The project uses .net libraries. To compile a project that uses .net libraries the cl.exe argument “/clr” is required. However: “/clr” can not be used in conjunction with “/EHsc” that is preset by the gradle cpp plugin. I have tried to understand the flow of the cpp plugin and I came up with a fairly hacky solution: Rewriting the generated compile-options.txt file…

So basically what I am asking is:

Can this be done easier without bending everything as far as I did?

Do you think you could make something about this process easier?

yours Martin.