Skip to main content
Participant
March 17, 2024
Answered

Adobe Animate, C extensibility, sample code not working

  • March 17, 2024
  • 1 reply
  • 827 views

Hey everyone,

 

Sorry to bother.

Recently I'm trying to call functions from cutomised .dll.

The instruction I follow is this one:

https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/C-Level_Extensibility/Integrating_C_functions.md

 

Here's what I do:

1) I use VS 2022, create a new project, choose Dynamic-link library

2) creating a Header file named mm_jsapi.h, and copying the sample code into this header file.

3) creating a cpp file named test.cpp, and copying the sample code under section 'Sample DLL implementation'.

4) build solution, and I get the test.dll file

5) test.dll is then renamed to Sample.dll, and moved to ..\Animate 2023\en_US\Configuration\External Libraries

6) creating Sample.jsfl, copying the jsfl code into it, then moving Sample.jsfl to ..\Configuration\Commands

7) restart Adobe Animate, and run the command

 

it jumps out an error message, says

 

I'm so confused now and I don't know what to do.

If anyone ever succeeded in calling .dll function, could you please share some ideas?

 

Much appreciated.

    This topic has been closed for replies.
    Correct answer aa35502922pebg

    Solved.

     

    The sample code on github is NOT complete, that is to say, there are missing lines of code.

    https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/C-Level_Extensibility/

    Integrating_C_functions.md

     

    1. The missing part

    Thanks to The Blender18590443wuel and his post @

    https://community.adobe.com/t5/animate-discussions/c-level-jsapi-array-object-returns-crash/m-p/13877627#M366451

    After copying the sample code from the official doc, add the code below

     

    MM_STATE
    
    void
    MM_Init()
    {
            /* (unsigned short*)L"computeSum"
            *  assume you write (unsigned short*)L"test1", then you use Sample.test1(a,b) to evoke your customised fuction in AN
    
            *  computeSum
            *  this is the name of your customised function in sample.c
    
            *  2
            *  this is the number of arguments your customised function expects to receive
            *  the function does a+b, so it needs 2 arguments */
            JS_DefineFunction((unsigned short*)L"computeSum", computeSum, 2);
    }

     

     

    2. If want to use sample.cpp instead of sample.c

    Then change this part.

    //this one is for sample.c
    #include "mm_jsapi.h"
    
    //this one is for sample.cpp
    extern "C"
    {
    #include "mm_jsapi.h"
    }

     

    1 reply

    aa35502922pebgAuthorCorrect answer
    Participant
    March 24, 2024

    Solved.

     

    The sample code on github is NOT complete, that is to say, there are missing lines of code.

    https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/C-Level_Extensibility/

    Integrating_C_functions.md

     

    1. The missing part

    Thanks to The Blender18590443wuel and his post @

    https://community.adobe.com/t5/animate-discussions/c-level-jsapi-array-object-returns-crash/m-p/13877627#M366451

    After copying the sample code from the official doc, add the code below

     

    MM_STATE
    
    void
    MM_Init()
    {
            /* (unsigned short*)L"computeSum"
            *  assume you write (unsigned short*)L"test1", then you use Sample.test1(a,b) to evoke your customised fuction in AN
    
            *  computeSum
            *  this is the name of your customised function in sample.c
    
            *  2
            *  this is the number of arguments your customised function expects to receive
            *  the function does a+b, so it needs 2 arguments */
            JS_DefineFunction((unsigned short*)L"computeSum", computeSum, 2);
    }

     

     

    2. If want to use sample.cpp instead of sample.c

    Then change this part.

    //this one is for sample.c
    #include "mm_jsapi.h"
    
    //this one is for sample.cpp
    extern "C"
    {
    #include "mm_jsapi.h"
    }

     

    Participant
    April 22, 2024

     

    Can you help me? Why does my execution keep reporting this error after completing your modifications?

     

     

    gcc -shared -o test.dll test.c
    
    C:\Users\ADMINI~1\AppData\Local\Temp\cccWXxpW.o:test.c:(.text+0x14): undefined reference to `mmEnv'
    C:\Users\ADMINI~1\AppData\Local\Temp\cccWXxpW.o:test.c:(.text+0x1d): undefined reference to `mmEnv'
    C:\Users\ADMINI~1\AppData\Local\Temp\cccWXxpW.o:test.c:(.text+0x3e): undefined reference to `mmEnv'
    C:\Users\ADMINI~1\AppData\Local\Temp\cccWXxpW.o:test.c:(.text+0x47): undefined reference to `mmEnv'

     

     

    Participant
    April 23, 2024
    undefined reference to `mmEnv'

    mmEnv is defined in mm_jsapi.h. Have you included it?

    Make sure mm_jsapi.h contains no error. Or paste your code.