Jump to content

C++ Managed/Native Hybrid Mod


Recommended Posts

Fellow Kerbonauts,

I am now ready to start developing my mods which I have planned for KSP.

I have a massive library of pretty nice c++ code that I have developed and maintained throughout the years.

I would really like to use this in my mod.

Many years ago I did use this in a hybrid managed cli/unmanaged program which was a total nightmare for a number of reasons: 1. There was no incremental linking meaning whole thing needed to be relinked on any code change(which took aaaages).  2. MS implementation was absolutely full of bugs(this was back in mid 2000s) 3. It is just plain miserable and ugly way to code

Has anything changed that will make this prospect any saner?  My c++ library compiles on Clang and GCC; having my mods run on linux and osx would be a real nice to have, there is no particular technical reason they should not compile as long as there is not some kind of barrier there I dont get.

Are there any massive difficulties in having managed/unmanaged code run under mono(as its not 'real' .net) ?

Anyone know of any nice ways to do this ?

I have been away from serious .net development for many years(except aspx) and am absolutely new to mono and unity (and ksp modding).

Helpful advice is welcome.  Unhelpful advice like do it in c# is not.

Gavin786

Link to comment
Share on other sites

[MOD - Moved to C# Plugin Development Help and Support subforums.

Yes, I am aware of the irony in that you clearly stated you are not coding in C#, but this is the subforum for discussing plugin development in general.]

Link to comment
Share on other sites

On 3/23/2019 at 4:55 AM, Lisias said:

Give a look on the Advanced Fly By Wire mod. I'm pretty sure you will find it useful to your needs.

Thank you for your reply Lisias, it was very helpful.

To those in the same or similar situation, this is what I have uncovered so far.

It seems that the Unity executable will not load any image that is not cli/safe.  Even if tools such as CorFlags are used to change the executable signature it seems that KSP will not run the code(I have yet to EXHAUSTIVLY test this but it certainly seems so for now).

The bigger problem though, even if one was willing to convert existing c++ code to cli/safe is that the Pdb2Mdb conversion tool does not seem to work correctly with c++ images.

Use of a debugger is a red line for me; I must have access to this.

My current situation is that I need to modify Pdb2Mdb to properly work with c++/cli or accept that I need to code this in C# or Visual Basic(more than likely) or some other .NET primary language.

I will try and modify Pdb2Mdb and see if I get any luck there.

Link to comment
Share on other sites

5 minutes ago, Gavin786 said:

The bigger problem though, even if one was willing to convert existing c++ code to cli/safe is that the Pdb2Mdb conversion tool does not seem to work correctly with c++ images.

I'm an idiot!

Give a peek on Principia too - hell of a project, they are reimplementing orbital mechanics using C++. So they solved this issue for sure!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...