Search Unity

Anyway to include cpp header as plugin without compiling them into .dll?

Discussion in 'Scripting' started by sylorrstar, May 18, 2018.

  1. sylorrstar

    sylorrstar

    Joined:
    May 18, 2018
    Posts:
    2
    Hi all, I am recently using Google Protobuf to feed data to my Unity3D project to update the game world. Firstly, I tried C# version of Protobuf, it works like a charm. However, the reality is my teammate is using cpp version of Protobuf/Protoc (and he uses it for some reason). In which case I can only get .h/.cc file in the run-time(or perhaps compile time, not quite sure, we gonna talk about it later). I have browsed the whole https://docs.unity3d.com/Manual/Plugins.html plugins page and it seems I have to compile my .h/.cc into .dll and add it into Unity3D project at compile time.

    One solution is making a .dll in the run-time, honestly it is kinda hard to me.
    Ideally, if I could write some C# scripts that can directly call the cpp function (with an "extern C" wrapper), that would be perfect. So I think my question is simple, is it possible to call cpp function without linking it as .dll?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The only supported method I'm aware of for adding c++ to Unity is via a dll plugin.
     
  3. sylorrstar

    sylorrstar

    Joined:
    May 18, 2018
    Posts:
    2
    Thanks, the good news is that the .h/.cc can be generated at compile time. I think I need to compile the generated file into .dll by cmake options.