Search Unity

Unity Plugin:

Discussion in 'Scripting' started by UDN_ff1fde89-a549-4fc9-bc1f-b1ab7431f7b9, Nov 11, 2017.

  1. UDN_ff1fde89-a549-4fc9-bc1f-b1ab7431f7b9

    UDN_ff1fde89-a549-4fc9-bc1f-b1ab7431f7b9

    Joined:
    Nov 11, 2017
    Posts:
    2
    Hey all. I can't get my plugin to work with Unity on Ubuntu 14.04.

    My plugin code:

    main.h
    Code (csharp):
    1.  
    2. #include <stdio.h>
    3.  
    4. extern "C" {
    5.     extern void gameInit();
    6.     extern int PrintANumber();
    7. }
    8.  
    main.cpp
    Code (csharp):
    1.  
    2. #include <stdio.h>
    3. #include "main.h"
    4. extern "C" {
    5.     void gameInit()
    6.     {
    7.         puts("GAME INITIALIZED!!!");
    8.         return;
    9.     }
    10.     int PrintANumber(){
    11.         return 5;
    12.     }
    13. }
    14.  
    I compile it with
    g++ -c -Wall -fPIC main.cpp
    g++ -shared -o libaigame.so main.o
    cp libaigame.so /media/progmaster/563C80473C8023D9/Unity/PortalAIL/Assets/Plugins/

    My Unity code is as follows:
    Code (csharp):
    1.  
    2. [DllImport("aigame")]
    3. public static extern void gameInit();
    4. [DllImport ("aigame")]
    5. private static extern int PrintANumber();
    6.  
    7. void Start ()
    8. {
    9.     Debug.Log (PrintANumber ());
    10.     //gameInit ();
    11. }
    12.  


    And it gives me an error:
    EntryPointNotFoundException: PrintANumber
    Main.Start () (at Assets/Main.cs:30)

    Can you help me?

     
  2. UDN_ff1fde89-a549-4fc9-bc1f-b1ab7431f7b9

    UDN_ff1fde89-a549-4fc9-bc1f-b1ab7431f7b9

    Joined:
    Nov 11, 2017
    Posts:
    2
    Solved by installing Eclipse C++ and modifying the plugin example code.