External dynamic libraries on mac



  • On 03/03/2014 at 08:37, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R15 
    Platform:    Mac  ;  
    Language(s) :     C++  ;

    ---------
    I'm using an external package that has dynamic libraries.
    On windows everything is working.

    On Mac I can compile and link, but the plugin is not started.
    Probably because the external libraries are not found.

    When I put these external libraries in the same folder as the plugin dynamic library it does not work?

    Where do I put or copy these external libraries, so cinema 4d knows where to find them?
    What setting do I use in xcode to define the location of the libraries?



  • On 03/03/2014 at 09:57, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    <ADDRESS>
    User Information:
    Cinema 4D Version:   R15 
    Platform:    Mac  ;  
    Language(s) :    
    C++  ;

    ---------
    </ADDRESS> I'm using an external package that has dynamic libraries.
    On windows everything is working.
    On Mac I can compile and link, but the plugin is not started.
    Probably because the external libraries are not found.
    When I put these external libraries in the same folder as the plugin dynamic library it does not work?
    Where do I put or copy these external libraries, so cinema 4d knows where to find them?
    What setting do I use in xcode to define the location of the libraries?

    I'd suggest putting them in the same folder as your plugin (on Win & OS X) and using

    - GeGetPluginPath() to inquire the path to your plugin

    - Loadlibrary()/FreeLibrary() (on Win)

    - dlopen()/Dlclose() (on OS X)

    to explictely load the libs from the location your want them to load. This avoids getting in trouble with assumptions of what is the current path (when it ain't).

    Best reards,

    Wilfried



  • On 03/03/2014 at 12:33, xxxxxxxx wrote:

    Thanks for the reply.
    Does it indeed means that we have to load the library our self?
    So, I can only call a routine in this library after I have loaded the library?
    Is the link to the routine not stored in the plugin library?

    In windows I do not need to do a Loadlibrary()/FreeLibrary().
    I add the code to my plugin, add links to the libraries, and then compile and link.
    The plugin then runs ok, including the code that uses the external libraries.
    So, I do not think I have to do a dlopen()/Dlclose() on OS X, but I do not know enough of the mac or xcode.

    On windows I can remove the libraries (the *.lib files) and the plugin still runs.
    That means imho that the external routines are included in the plugin library (the *.cdl64 file).

    On Mac I'm using *.dylib libraries, perhaps I should use static libraries (*.a files)?

    -Pim



  • On 03/03/2014 at 13:26, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Thanks for the reply.
    Does it indeed means that we have to load the library our self?
    <span style="font-size: 12px; line-height: 1.4;">So, I can only call</span><span style="font-size: 12px; line-height: 1.4;"> </span>a routine in this library after I have loaded the library?
    Is the link to the routine not stored in the plugin library?
    In windows I do not need to do a <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;">Loadlibrary()/FreeLibrary().</span>
    <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;">I add the code to my plugin, add links to the libraries, and then compile and link.</span>
    <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;">The plugin then runs ok, including the code that uses the external libraries.</span>
    <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;">So, I do not think I have to do a </span><span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;">dlopen()/Dlclose() on OS X, but I do not know enough of the mac or xcode.</span>
    <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;"></span>
    <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;">On windows I can remove the libraries (the *.lib files) and the plugin still runs.</span>
    <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;">That means imho that the external routines are included in the plugin library (the *.cdl64 file).</span>
    <span style=": rgb248, 248, 252; font-size: 12px; line-height: 1.4;"></span>
    On Mac I'm using *.dylib libraries, perhaps I should use static libraries (*.a files)?
    -Pim

    It depends on the plugin library and there are several ways to deal with it - my preferred way would be to have loading/unloading under explicit control and not to dependent on environment variables or similar stuff to get external libs loaded; your choice …

    For more information, have a look at Apple's doc pages: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryUsageGuidelines.html

    Best regards,

    Wlfried



  • On 03/03/2014 at 13:28, xxxxxxxx wrote:

    If those are the Chilkat libraries, you absolutely need to use the static libs and link to them, just as you would on Windows. Don't use the dynamic ones.

    Steve



  • On 04/03/2014 at 00:50, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    If those are the Chilkat libraries, you absolutely need to use the static libs and link to them, just as you would on Windows. Don't use the dynamic ones.

    Steve

    Yes, you are correct. That solved it.
    I am now struggling, like you told me, with the chilkat string handling.
    It seemed much easier on windows than on a Mac(?).

    -Pim


Log in to reply