Using external libraries.

About Monkey 2 Forums Monkey 2 Programming Help Using external libraries.

This topic contains 6 replies, has 5 voices, and was last updated by  abakobo 1 year, 6 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10690

    TurkeyLurker
    Participant

    I have a library that I have tested and successfully used in C. The library has a function:

    void swe_set_ephe_path(char *path)

    I am importing the library where this function is stored into monkey2, but I am not sure about the extern declaration. I also am not sure on how to properly use the function in Monkey2. What could I be doing wrong?

    [/crayon]
    #10691

    CopperCircle
    Participant

    Hi, take a look at other modules that use c libs:

    http://monkeycoder.co.nz/forums/topic/tinyaes-wrapper/

    #10692

    DruggedBunny
    Participant

    Can’t see anything obviously wrong, but also of course can’t test it. Might be worth trying to change path:Byte Ptr to path:CString, though I suspect they work out the same…

    This was my earlier effort at importing an external function, though slightly different circumstances… yours looks pretty much the same setup, though:

    http://monkeycoder.co.nz/forums/topic/simple-win32-api-call-attempt/

    What was the error message?

    #10693

    abakobo
    Participant

    Mx2 strings are not Cstrings. Checkout the toCString method.

    #10701

    Mark Sibly
    Keymaster

    Use the built-in CString type for extern char* type strings, eg:

    #10704

    TurkeyLurker
    Participant

    Thank you all! I set the name of the function to the C++ equivalent (no underscore at the beginning), and changed the Byte Ptr to CString in the extern, and now it all works.

    [/crayon]
    #10705

    abakobo
    Participant

    Wow though I had to convert it myself!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.